Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kivy
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.uix.button import Button
- from kivy.uix.label import Label
- from kivy.uix.gridlayout import GridLayout
- from kivy.uix.textinput import TextInput
- from kivy.properties import ObjectProperty
- from kivy.uix.screenmanager import ScreenManager, Screen
- from kivy.uix.behaviors.focus import FocusBehavior
- from kivy.factory import Factory
- from kivy.uix.widget import Widget
- # You can create your kv code in the Python file
- Builder.load_string("""
- <KeypadTextInput@TextInput>:
- keypad: None
- on_focus: root.keypad._on_focus(*args)
- <Idle>:
- BoxLayout:
- Button:
- text: "Delivery"
- on_press:
- # You can define the duration of the change
- # and the direction of the slide
- root.manager.transition.direction = 'right'
- root.manager.transition.duration = 1
- root.manager.current = 'LockBox'
- Button:
- text: "Collect"
- on_press:
- # You can define the duration of the change
- # and the direction of the slide
- root.manager.transition.direction = 'left'
- root.manager.transition.duration = 1
- root.manager.current = 'BoxPin'
- <Collecting>:
- BoxLayout:
- Label:
- text: ""
- on_press:
- root.manager.transition.direction = 'right'
- root.manager.transition.duration = 1
- root.manager.current = 'LockBox'
- Button:
- text: "Collect"
- on_press:
- # You can define the duration of the change
- # and the direction of the slide
- root.manager.transition.direction = 'left'
- root.manager.transition.duration = 1
- root.manager.current = 'BoxPin'
- <LockBox>:
- GridLayout:
- cols:3
- rows:2
- spacing: 10
- padding: 10
- Label:
- text: "Please select lock box size "
- halign: 'center'
- valign: 'top'
- Button:
- text: "SMALL"
- on_press:
- root.manager.transition.direction = 'right'
- root.manager.current = 'UnitPin'
- Button:
- text: "MEDIUM"
- on_press:
- root.manager.transition.direction = 'right'
- root.manager.current = 'UnitPin'
- Button:
- text: "LARGE"
- on_press:
- root.manager.transition.direction = 'right'
- root.manager.current = 'UnitPin'
- <BoxPin>:
- FloatLayout:
- Button:
- text: 'Back'
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- size_hint_x: 0.250
- size_hint_y: 0.150
- pos_hint: {'x': 0.025, 'y': 0.03}
- on_release:
- root.manager.transition.direction = 'right'
- root.manager.current = 'Idle'
- Button:
- id: startStopButton
- text: 'Unlock'
- color: 1.0, 0.6, 0.0, 1
- size_hint_x: 0.250
- size_hint_y: 0.150
- pos_hint: {'x': 0.725, 'y': 0.03}
- on_release:
- root.startStop()
- Label:
- text: "Enter Locker Number and SMS code"
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- pos_hint: {'x': -.265,'y':.35}
- Label:
- text: "Locker No."
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- pos_hint: {'x': -.42, 'y':.1}
- Label:
- text: "SMS Code"
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- pos_hint: {'x': -.42, 'y': -.15}
- FloatLayout:
- KeypadTextInput:
- keypad: keypad
- color: 1.0, .6, 0, 1
- font_size: 20
- size_hint_x: .275
- size_hint_y: .15
- pos_hint: {'x': .15,'y': .525}
- KeypadTextInput:
- keypad: keypad
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- size_hint_x: .275
- size_hint_y: .15
- pos_hint: {'x': .15,'y': .275}
- Keypad:
- id: keypad
- cols: 3
- rows: 4
- spacing: 10
- pos_hint: {'x': .475,'y': .25}
- size_hint: (.5,.7)
- ############################################################################################
- <UnitPin>:
- FloatLayout:
- Button:
- text: 'Back'
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- size_hint_x: 0.250
- size_hint_y: 0.150
- pos_hint: {'x': 0.025, 'y': 0.03}
- on_release:
- root.manager.transition.direction = 'left'
- root.manager.current = 'Idle'
- Button:
- id: unitSelector
- text: 'Select'
- color: 1.0, 0.6, 0.0, 1
- size_hint_x: 0.250
- size_hint_y: 0.150
- pos_hint: {'x': 0.725, 'y': 0.03}
- on_release:
- root.startStop()
- Button:
- id: Scanner
- text: 'Scan'
- size_hint_x: 0.4
- size_hint_y: 0.15
- pos_hint:{'x': 0.3,'y': 0.03}
- on_release:
- #root.polarity()
- Label:
- text: "Enter Unit Number"
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- pos_hint: {'x': -.265,'y':.35}
- Label:
- text: "Unit No."
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- pos_hint: {'x': -.42, 'y':.1}
- Label:
- text: "Bar Code"
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- pos_hint: {'x': -.42, 'y': -.15}
- FloatLayout:
- KeypadTextInput:
- keypad: keypad
- color: 1.0, .6, 0, 1
- font_size: 20
- size_hint_x: .275
- size_hint_y: .15
- pos_hint: {'x': .15,'y': .525}
- KeypadTextInput:
- keypad: keypad
- color: 1.0, 0.6, 0.0, 1
- font_size: 20
- size_hint_x: .275
- size_hint_y: .15
- pos_hint: {'x': .15,'y': .275}
- Keypad:
- id: keypad
- cols: 3
- rows: 4
- spacing: 10
- pos_hint: {'x': .475,'y': .25}
- size_hint: (.5,.7)
- """)
- # Create a class for all screens in which you can include
- # helpful methods specific to that screen
- class Idle(Screen):
- pass
- class LockBox(Screen):
- pass
- class UnitPin(Screen):
- pass
- class BoxPin(Screen):
- LockerNo_input = ObjectProperty()
- PinNo_input = ObjectProperty()
- pass
- class BoxPin(Screen):
- def startStop(self):
- if self.ids.startStopButton.text == "Start":
- self.ids.startStopButton.text = "Stop"
- else:
- self.ids.startStopButton.text = "Start"
- def polarity(self):
- if self.ids.polButton.text == "Polarity +":
- self.ids.polButton.text = "Polarity -"
- else:
- self.ids.polButton.text = "Polarity +"
- class KeypadButton(Button):
- def on_touch_down(self, touch):
- if self.collide_point(*touch.pos):
- FocusBehavior.ignored_touch.append(touch)
- return super(KeypadButton, self).on_touch_down(touch)
- class Keypad(GridLayout):
- target = ObjectProperty(None, allownone=True)
- def __init__(self, **kwargs):
- super(Keypad, self).__init__(**kwargs)
- self.cols = 3
- for x in list(range(1, 10)) + ['<-', 0, 'Enter']:
- btn = KeypadButton(text=str(x), on_release=self._on_release)
- self.add_widget(btn)
- def _on_focus(self, value, ti):
- self.target = value and ti
- def _on_release(self, instance, *largs):
- if self.target:
- if instance.text == 'Enter':
- print("Enter: {}".format(self.target.text))
- self.target.text = ''
- elif instance.text == '<-':
- if self.target.text:
- self.target.text = self.target.text[:-1]
- #else:
- #self.target.text += str(instance.text)
- print(self.target.text)
- elif self.target == None:
- print('none')
- else:
- print(instance.text)
- # The ScreenManager controls moving between screens
- screen_manager = ScreenManager()
- # Add the screens to the manager and then supply a name
- # that is used to switch screens
- screen_manager.add_widget(Idle(name="Idle"))
- screen_manager.add_widget(LockBox(name="LockBox"))
- screen_manager.add_widget(BoxPin(name="BoxPin"))
- screen_manager.add_widget(UnitPin(name="UnitPin"))
- class Dlocker(App):
- global dbHost
- global dbName
- global dbUser
- global dbPass
- dbHost = 'localhost'
- dbName = 'DB_GAP'
- dbUser = 'Gaptech'
- dbPass = 'dlocker'
- def build(self):
- return screen_manager
- dlocker = Dlocker()
- dlocker.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement