Created
February 24, 2017 07:58
-
-
Save Crowbrammer/464ae3ae3ddd7d33a9eb64d856acacd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ScreenManagement: | |
ModelAddScreen | |
<ModelAddScreen>: | |
name: 'ScreenTemplateScreen' | |
ModelAddLayout | |
<PrimaryOverlay>: | |
ModelAddLayout | |
AppWideHUD | |
<ModelAddLayout>: | |
orientation: 'vertical' | |
padding: 20, 20 | |
Label: | |
id: title_label | |
text: 'Model Add Screen' | |
font_size: '30dp' | |
# text_size: '15dp' | |
TextInput: | |
id: model_add_name | |
text: 'Add your model name here' | |
multiline: False | |
BoxLayout: | |
padding: 20, 20 | |
Button: | |
id: num_positions | |
text: '# of positions' | |
multiline: False | |
on_release: root.dropdown.open() | |
Button: | |
id: machine_id | |
text: 'DD, 2 options. All, or screen' | |
BoxLayout: | |
Label: | |
id: restricted_possible_label | |
text: 'Does this model contain restrictable positions?' | |
font_size: '15dp' | |
Switch: | |
id: restriction_prone_switch | |
Button: | |
id: add_model_confirm | |
text: 'Add Model' | |
font_size: '30dp' | |
on_release: root.record_new_model() | |
<AppWideHUD> | |
size_hint_y: None | |
height: '20dp' | |
Button: | |
text: 'Spch Bubble' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the unused machines screen done | |
import libs.apa_database | |
from kivy.app import App | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.button import Button | |
from kivy.uix.dropdown import DropDown | |
from kivy.uix.screenmanager import ScreenManager, Screen | |
from kivy.uix.scrollview import ScrollView | |
class ScreenManagement(ScreenManager): | |
pass | |
class ModelAddScreen(Screen): | |
pass | |
class ModelAddLayout(BoxLayout): | |
def __init__(self, **kwargs): | |
super(ModelAddLayout, self).__init__(**kwargs) | |
model_name = self.ids.model_add_name.text | |
# create a dropdown with 10 buttons | |
dropdown = DropDown() | |
for index in range(1,11): | |
# When adding widgets, we need to specify the height manually | |
# (disabling the size_hint_y) so the dropdown can calculate | |
# the area it needs. | |
btn = Button(text='Value %d' % index, size_hint_y=None, height=44) | |
# for each button, attach a callback that will call the select() method | |
# on the dropdown. We'll pass the text of the button as the data of the | |
# selection. | |
btn.bind(on_release=lambda btn: dropdown.select(btn.text)) | |
# then add the button inside the dropdown | |
dropdown.add_widget(btn) | |
#dropdown.bind(on_select=lambda instance, x, e=self.ids.num_positions: setattr(e, 'text', x)) | |
def record_new_model(self): | |
model_name = self.ids.model_add_name.text | |
num_positions = int(self.ids.num_positions.text) | |
print(model_name) | |
print('num_positions: ' + str(num_positions)) | |
for i in range(1, num_positions + 1): | |
libs.apa_database.insert_data(tb='modelID_positionnum', col1='modelID', \ | |
data1=model_name, col2='positionNum', data2=i) | |
class PrimaryOverlay(ScrollView): | |
pass | |
class AppWideHUD(BoxLayout): | |
pass | |
class ModelAddApp(App): | |
def build(self): | |
ModelAddLayout() | |
# A | |
if __name__ == '__main__': | |
ModelAddApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment