File tree Expand file tree Collapse file tree 6 files changed +13
-26
lines changed
apps/android_pythonnative_3/app/src/main/python
libs/pythonnative/pythonnative Expand file tree Collapse file tree 6 files changed +13
-26
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ def create_constraint_layout(context):
1919
2020 # Create BottomNavigationView
2121 bottom_nav = BottomNavigationView (context )
22- bottom_nav .setId (View .generateViewId ()) # Add this line to generate unique id for the view
22+ bottom_nav .setId (
23+ View .generateViewId ()
24+ ) # Add this line to generate unique id for the view
2325
2426 # Create Menu for BottomNavigationView
2527 menu = bottom_nav .getMenu ()
@@ -34,7 +36,7 @@ def create_constraint_layout(context):
3436 # Add BottomNavigationView to ConstraintLayout
3537 nav_layout_params = ConstraintLayout .LayoutParams (
3638 ConstraintLayout .LayoutParams .MATCH_PARENT ,
37- ConstraintLayout .LayoutParams .WRAP_CONTENT
39+ ConstraintLayout .LayoutParams .WRAP_CONTENT ,
3840 )
3941 # Set the constraints here
4042 nav_layout_params .bottomToBottom = ConstraintLayout .LayoutParams .PARENT_ID
Original file line number Diff line number Diff line change 1- # pythonnative.py
2-
31import pythonnative as pn
42
53
@@ -13,8 +11,3 @@ def create_pn_layout(context):
1311 layout .add_view (button )
1412
1513 return layout .native_instance
16-
17- # from java import jclass
18- # LinearLayout = jclass("android.widget.LinearLayout")
19- # layout = LinearLayout(context)
20- # return layout
Original file line number Diff line number Diff line change 55 from java import jclass
66
77 class Button (View ):
8- native_class = jclass ("android.widget.Button" )
9-
108 def __init__ (self , context , title : str = "" ) -> None :
119 super ().__init__ ()
10+ self .native_class = jclass ("android.widget.Button" )
1211 self .native_instance = self .native_class (context )
1312 self .set_title (title )
1413
@@ -22,10 +21,9 @@ def get_title(self) -> str:
2221 from rubicon .objc import ObjCClass
2322
2423 class Button (View ):
25- native_class = ObjCClass ("UIButton" )
26-
2724 def __init__ (self , title : str = "" ) -> None :
2825 super ().__init__ ()
26+ self .native_class = ObjCClass ("UIButton" )
2927 self .native_instance = self .native_class .alloc ().init ()
3028 self .set_title (title )
3129
Original file line number Diff line number Diff line change 55 from java import jclass
66
77 class Label (View ):
8- native_class = jclass ("android.widget.TextView" )
9-
108 def __init__ (self , context , text : str = "" ) -> None :
119 super ().__init__ ()
10+ self .native_class = jclass ("android.widget.TextView" )
1211 self .native_instance = self .native_class (context )
1312 self .set_text (text )
1413
@@ -22,10 +21,9 @@ def get_text(self) -> str:
2221 from rubicon .objc import ObjCClass
2322
2423 class Label (View ):
25- native_class = ObjCClass ("UILabel" )
26-
2724 def __init__ (self , text : str = "" ) -> None :
2825 super ().__init__ ()
26+ self .native_class = ObjCClass ("UILabel" )
2927 self .native_instance = self .native_class .alloc ().init ()
3028 self .set_text (text )
3129
Original file line number Diff line number Diff line change 55 from java import jclass
66
77 class LinearLayout (View ):
8- native_class = jclass ("android.widget.LinearLayout" )
9-
108 def __init__ (self , context ) -> None :
119 super ().__init__ ()
10+ self .native_class = jclass ("android.widget.LinearLayout" )
1211 self .native_instance = self .native_class (context )
13- self .native_instance .setOrientation (self .native_class .VERTICAL ) # Set orientation to vertical
12+ self .native_instance .setOrientation (self .native_class .VERTICAL )
1413 self .views = []
1514
1615 def add_view (self , view ):
@@ -21,10 +20,9 @@ def add_view(self, view):
2120 from rubicon .objc import ObjCClass
2221
2322 class LinearLayout (View ):
24- native_class = ObjCClass ("UIStackView" )
25-
2623 def __init__ (self ) -> None :
2724 super ().__init__ ()
25+ self .native_class = ObjCClass ("UIStackView" )
2826 self .native_instance = self .native_class .alloc ().initWithFrame_ (
2927 ((0 , 0 ), (0 , 0 ))
3028 )
Original file line number Diff line number Diff line change 55 from java import jclass
66
77 class Screen (View ):
8- native_class = jclass ("android.app.Activity" )
9-
108 def __init__ (self ):
119 super ().__init__ ()
10+ self .native_class = jclass ("android.app.Activity" )
1211 self .native_instance = self .native_class ()
1312 self .layout = None
1413
@@ -29,10 +28,9 @@ def show(self):
2928 from rubicon .objc import ObjCClass
3029
3130 class Screen (View ):
32- native_class = ObjCClass ("UIViewController" )
33-
3431 def __init__ (self ):
3532 super ().__init__ ()
33+ self .native_class = ObjCClass ("UIViewController" )
3634 self .native_instance = self .native_class .alloc ().init ()
3735 self .layout = None
3836
You can’t perform that action at this time.
0 commit comments