def on_dict(self, instance, value): # 2020_03_10 Sim: Why only import Spinner here? at the top of the file # it was causing a crash when starting in a thread - no idea why from kivy.uix.spinner import Spinner for n, topic in enumerate(sorted(value)): check_box = CheckBox() self.add_widget(check_box) self.add_widget(TextInput(text=str(n))) spinner = Spinner( values=['dvs', 'frame', 'pose6q', 'cam', 'imu', 'flowMap']) if 'events' in topic: spinner.text = 'dvs' check_box.active = True elif 'image' in topic or 'depthmap' in topic: spinner.text = 'frame' check_box.active = True elif 'pose' in topic: spinner.text = 'pose6q' check_box.active = True elif 'flow' in topic: spinner.text = 'flowMap' check_box.active = True self.add_widget(spinner) self.add_widget(TextInput(text=topic))
def add_row(self, instance): """ Add a row to the main exchange screen :param instance: :return: """ self.num_rows += 1 keys_button = Button(text='Keys', size_hint_x=0.2, id='%d' % self.num_rows) keys_button.bind(on_release=self.enter_keys) self.content.add_widget(keys_button) self.keys_button.append(keys_button) address = TextInput(size_hint_x=0.2, padding=[6, 10, 6, 10], multiline=False, font_size=18, id='%d' % self.num_rows) address.bind(text=self.check_address) self.content.add_widget(address) self.address.append(address) unit = Spinner(values=self.currencies, text=self.currencies[0], size_hint_x=0.2, id='%d' % self.num_rows) self.selected_unit = self.currencies[0] unit.bind(text=self.set_unit) self.content.add_widget(unit) self.unit.append(unit) rates = Button(text='Rates', size_hint_x=0.2, id='%d' % self.num_rows) rates.bind(on_release=self.enter_rates) self.content.add_widget(rates) self.rates.append(rates) bot = Spinner(values=self.bots, text=self.bots[0], size_hint_x=0.2, id='%d' % self.num_rows) self.selected_bot = self.bots[0] bot.bind(text=self.set_bot) self.content.add_widget(bot) self.bot.append(bot) if isinstance(instance, dict): keys_button.text = instance['public'][:8] + ' / ' + instance[ 'secret'][:8] address.text = instance['address'] unit.text = instance['unit'] rates.text = instance['ask'] + ' | ' + instance['bid'] bot.text = instance['bot']
def add_row(self, instance): """ Add a row to the main exchange screen :param instance: :return: """ self.num_rows += 1 keys_button = Button(text='Keys', size_hint_x=0.2, id='%d' % self.num_rows) keys_button.bind(on_release=self.enter_keys) self.content.add_widget(keys_button) self.keys_button.append(keys_button) address = TextInput(size_hint_x=0.2, padding=[6, 10, 6, 10], multiline=False, font_size=18, id='%d' % self.num_rows) address.bind(text=self.check_address) self.content.add_widget(address) self.address.append(address) unit = Spinner(values=self.currencies, text=self.currencies[0], size_hint_x=0.2, id='%d' % self.num_rows) self.selected_unit = self.currencies[0] unit.bind(text=self.set_unit) self.content.add_widget(unit) self.unit.append(unit) rates = Button(text='Rates', size_hint_x=0.2, id='%d' % self.num_rows) rates.bind(on_release=self.enter_rates) self.content.add_widget(rates) self.rates.append(rates) bot = Spinner(values=self.bots, text=self.bots[0], size_hint_x=0.2, id='%d' % self.num_rows) self.selected_bot = self.bots[0] bot.bind(text=self.set_bot) self.content.add_widget(bot) self.bot.append(bot) if isinstance(instance, dict): keys_button.text = instance['public'][:8] + ' / ' + instance['secret'][:8] address.text = instance['address'] unit.text = instance['unit'] rates.text = instance['ask'] + ' | ' + instance['bid'] bot.text = instance['bot']
def getUI(self): """get the ui element""" if 'enum' in self._typeInfo: result = Spinner() result.values = self._typeInfo['enum'] elif self._typeInfo['type'].lower() == 'boolean': result = Spinner() result.values = ['true', 'false'] else: result = TextInput() if self.value: result.text = self.value.lower() skin = sm.getSkin('text', self.asset) result.size = sm.getControlSize(skin, self.asset) self.uiEl = result self.prepareUiElement() result.bind(text=self.value_changed) return result
# Label título ======================================== label = Label() label.size_hint = 0.5, 1.5 label.text = 'Gerenciador de clientes e pedidos' # Label resumo ======================================== lb_resumo = Label() """ Armazenar os valores no Spinner""" spin = Spinner() spin.size_hint = 0.2, 0.5 spin.pos_hint = {'top': 0.5} spin.text = 'Clientes' lb_cidade = Label() lb_nuped = Label() lb_data = Label() lb_valor = Label() """ --------------------------------------------------------------------------""" # Botãos ==================================== size_bt = [0.5, 1] bt_ok = Button() bt_ok.size_hint = size_bt bt_ok.text = 'Confirmar' bt_ok.disabled = True
def getPropertiesPopup(self): popup = Popup( title="Editing Properties", # Sets the title of popup content=FloatLayout(size=self.size), size_hint=(0.5, 0.8)) # Creates a Text Input to input the volume of liquid to used for the question volumeInput = TextInput( size_hint=(0.5, 0.1), pos_hint={ 'center_x': 0.5, 'center_y': 0.6 }, hint_text="Type the title...", multiline=False, ) if self.currentTitle != "": # Updates the text in the text input if values are already entered for that parameter volumeInput.text = self.currentTitle volumeInput.bind( text=self.titleTextInputCallback ) # self.volumeTextCallback is called on selection so that self.currentPopupValues is updated nums = [] for i in range(1, len(TaskManager.newTaskQuestions) + 1): nums.append(str(i)) nums = tuple(nums) valve = Spinner( size_hint=(0.6, 0.1), pos_hint={ 'center_x': 0.5, 'center_y': 0.75 }, text="Questions Per Sheet", values=nums # The valves that the user can select are numbered 1-6 ) if self.currentQuestionsPerSheet != 0: # Updates the text in the spinner if values are already entered for that parameter valve.text = str(self.currentQuestionsPerSheet) valve.bind( text=self.valveSpinnerCallback ) # self.valveSpinnerCallback is called on selection so that self.currentPopupValues is updated # Creates a confirm button # Button checks if the values that user selected for the parameters are correct # If the values are correct, self.currentPopupValues is inserted into the main Task Dictionary (self.newTaskQuestions) # In addition, the popup is closed and the Details Button displays a description of the values in a human-readable form confirmButton = Button(size_hint=(0.45, 0.1), pos_hint={ 'center_x': 0.25, 'center_y': 0.3 }, text="Confirm") confirmButton.bind(on_release=self.propertiesPopupConfirmCallback ) # Calls self.defaultPopupConfirmCallback on press # Creates a cancel button which closes the popup cancelButton = Button(size_hint=(0.45, 0.1), pos_hint={ 'center_x': 0.75, 'center_y': 0.3 }, text="Cancel") cancelButton.bind( on_release=self.defaultPopupCancelCallback ) # Calls self.defaultPopupCancelCallback which closes the popup # Adds all of the widgets created in this function to the popup popup.content.add_widget(volumeInput) popup.content.add_widget(valve) popup.content.add_widget(confirmButton) popup.content.add_widget(cancelButton) popup.open() # Opens the popup return popup # Returns the popup, so it can be saved to a variable if needed
def generate_item_detail_popup(self, item_index=None): """ The popup used by add_item_popup and edit_item_popup. Abstracts the code so I don't write it twice. If item_id is None, then this function will produce the add_item_popup. If item_id is defined, then this function will autofill the fields of the popup with the item details. """ #add item panel popup_pane = GridLayout(cols=1, padding=10) #1 column. everything will be stacked. name_input_pane = BoxLayout(orientation="horizontal") #label then textinput quantity_number_input_pane = BoxLayout(orientation="horizontal") #label then textinput quantity_units_input_pane = BoxLayout(orientation="horizontal") #label then textinput popup_pane.add_widget(name_input_pane) popup_pane.add_widget(quantity_number_input_pane) popup_pane.add_widget(quantity_units_input_pane) #The name input row name_input_label = Label(text="Item Name: ") name_input_text_input = TextInput(text="", multiline=False, font_size="30sp", halign="center") name_input_text_input.bind(text=self.name_input_callback) name_input_pane.add_widget(name_input_label) name_input_pane.add_widget(name_input_text_input) #The quantity number input row quantity_number_input_label = Label( text="Quantity Number: (Can be decimal, e.g. 4, 12, 1.5, etc.)") quantity_number_input_text_input = TextInput(text="", input_filter="float", multiline=False, font_size="30sp", halign="center") quantity_number_input_text_input.bind( text=self.quantity_input_callback) quantity_number_input_pane.add_widget(quantity_number_input_label) quantity_number_input_pane.add_widget(quantity_number_input_text_input) #The quantity units input row quantity_units_input_label = Label( text="Quantity Units: (A word or two, e.g. cartons, ounces, etc.)") quantity_units_input_text_input = TextInput(text="", multiline=False, font_size="30sp", halign="center") quantity_units_input_text_input.bind( text=self.quantity_units_input_callback) quantity_units_input_pane.add_widget(quantity_units_input_label) quantity_units_input_pane.add_widget(quantity_units_input_text_input) #expiry date optional label add_item_expiry_row_label = Label( text="Optional: (select none or all 3)") popup_pane.add_widget(add_item_expiry_row_label) #expiry date row (month: day: year: ; a row of 3 cols of text entries) add_item_expiry_date_pane = GridLayout(cols=3) popup_pane.add_widget(add_item_expiry_date_pane) #expiry month months = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") add_item_expiry_month_input = Spinner(text="Month", values=months) add_item_expiry_month_input.bind(text=self.month_input_callback) #triggers a callback whenever a value is selected add_item_expiry_date_pane.add_widget(add_item_expiry_month_input) #expiry day self.days = ("Day - Pick a month first", "If you want February 29,", "pick a leap year first") #set blank by default, updates when month is selected self.add_item_expiry_day_input = Spinner(text="Day", values=self.days) #made self. to target from day_update_on_month_input self.add_item_expiry_day_input.bind(on_press=self.day_update_callback) #updating day list whenever user clicks on it self.add_item_expiry_day_input.bind(text=self.day_input_callback) #saving day value user selects self.add_item_expiry_day_input.color = (0, 0, 0, 0.2) #making the day color dark as if it's disabled self.add_item_expiry_day_input.disabled = True #actually disabling the button add_item_expiry_date_pane.add_widget(self.add_item_expiry_day_input) #expiry year #generating year options right_now = datetime.date.today() current_year = right_now.year #print(current_year); year_gen = [] year_range = 15 #giving a range of now to 15 years from now. for i in range(0, year_range + 1): year_gen.append(str(current_year + i)) years = tuple(year_gen) add_item_expiry_year_input = Spinner(text="Year", values=years) add_item_expiry_year_input.bind(text=self.year_input_callback) add_item_expiry_date_pane.add_widget(add_item_expiry_year_input) #date input info label date_input_info_label = Label( text="To make things easy, first enter Year, then Month, then Day." ) popup_pane.add_widget(date_input_info_label) #resetting date variables because they persist through item creation self.new_item_day = None self.new_item_month = None self.new_item_year = None #Add Item button add_item_button = Button(text="Add Item!", size_hint_y=None, font_size="25sp") #default is 15sp add_item_button.bind(on_press=self.save_item) popup_pane.add_widget(add_item_button) popup = Popup(title="Add an Item", content=popup_pane) #add_item_button.bind(on_release=popup.dismiss); #add popup close button popup_pane_close_button = Button(text="Cancel") popup_pane_close_button.bind(on_press=popup.dismiss) popup_pane.add_widget(popup_pane_close_button) #autofilling - this is an edit popup if (item_index is not None): popup.title = "Edit an Item" item = fridge.item_list[int(item_index)] #the id is actually the index of the item in the item list name_input_text_input.text = item.name quantity_number_input_text_input.text = str(item.quantity) quantity_units_input_text_input.text = item.quantity_units expiry_date = item.expiry if (expiry_date is not None): month = expiry_date.month month_str = months[month - 1] #subtracting 1 because the index of january is 0 (value of january is 1) day = expiry_date.day year = expiry_date.year add_item_expiry_year_input.text = str(year) add_item_expiry_month_input.text = month_str self.add_item_expiry_day_input.disabled = False #enabling the day button for items who already have a day value self.add_item_expiry_day_input.text = str(day) add_item_button.text = "Save Item Changes!" add_item_button.id = item_index #passing item index so it can be used by save_item add_item_button.bind(on_press=self.save_item) return popup