def build(self): self.itemlist = [] for item in self.mylist: itemdict = {"id": item[0], "value": item[1]} itemdict["widget"] = QListWidgetItem(itemdict["value"], self) self.itemlist.append(itemdict)
def __init__(self, start, hive_connection): super(Kitchen, self).__init__() self.setupUi(self) # Hive database self.database_connector = hive_connection self.recipe_reader = RecipeReader(self.database_connector) self.recipe_reader.load_recipes() # Recipe List self.recipes = self.recipe_reader.get_recipes() item = QListWidgetItem('< None >') self.recipe_list.addItem(item) for recipe in self.recipes: item = QListWidgetItem(recipe) self.recipe_list.addItem(item) self.recipe_list.itemClicked.connect(self.set_ingredients) self.recipe_list.currentItemChanged.connect(self.clear_table) self.regex = re.compile('([0-9,.]+)([a-zA-Z]*)') self.start = start self.cancel_bt.clicked.connect(self.show_start) # name widget chooser self.mid = MealInputDialog('Title', 'Message', 'Name', 'Links', ('Cancel', 'Accept'), lambda x, y: print(x)) # language tag self.lang_tag = 'de' # language dicts self.stuff_hor_header_labels = { 'en': ['Amount', 'Unit', 'Name'], 'de': ['Menge', 'Einheit', 'Name'] } self.weekly_hor_header_labels = {'en': 'Meal', 'de': 'Gericht'} self.weekly_vert_header_labels = { 'en': [ 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday' ], 'de': [ 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag' ] } self.set_language_label_text = { 'en': 'set Language:', 'de': 'Sprache wechseln:' } self.rad_buttons_text = { 'en': [ 'Calories Summation', 'Show stock (empty things)', 'Show stock (existing things)', 'Bought goods' ], 'de': [ 'Kalorienrechner', 'Leere Nahrungsmittel', 'Vorhandene Nahrungsmittel', 'Einkaufsinventur' ] } self.tab_text = { 'en': ['Recipes', 'Weekly Rota', 'Playlist'], 'de': ['Rezepte', 'Wochenplan', 'Playlist'] } self.buttons_text = { 'en': [('Calculate calories', 'Push to Database'), 'Cancel'], 'de': [('Kalorien berechnen', 'Übernehmen'), 'Zurück'] } self.button_bought_calc_val = True # Tables self.stuff_table.setColumnCount(3) if not pyside_import: self.stuff_table.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) else: self.stuff_table.horizontalHeader().setResizeMode( QHeaderView.Stretch) self.weekly_tw.setColumnCount(1) self.weekly_tw.setRowCount(7) self.toggle_language() if not pyside_import: self.weekly_tw.verticalHeader().setSectionResizeMode( QHeaderView.Stretch) self.weekly_tw.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) else: self.weekly_tw.verticalHeader().setResizeMode(QHeaderView.Stretch) self.weekly_tw.horizontalHeader().setResizeMode( QHeaderView.Stretch) # Time self.time_lcd.setDigitCount(8) timer = QTimer(self) timer.timeout.connect(self.show_time) timer.start(1000) self.show_time() # Timer self.timer_lcd.setDigitCount(8) self.timer_dial.setMaximum(3600) if pyside_import: self.timer_dial.dialMoved.connect(self.set_timer) else: self.timer_dial.valueChanged.connect(self.set_timer) self.timer_timer = QTimer(self) self.timer_timer.timeout.connect(self.count_downwards) self.timer_bt.clicked.connect(self.timer_start) self.timer_time = 0 self.timer_running = False bl_pixmap = QPixmap('icons/aperture.png') red_pixmap = QPixmap('icons/aperture_red.png') self.icon_bl = QIcon() self.icon_bl.addPixmap(bl_pixmap) self.icon_red = QIcon() self.icon_red.addPixmap(red_pixmap) # Music buttons # prev prev_icon = QIcon() prev_pixmap = QPixmap('icons/prev.png') prev_icon.addPixmap(prev_pixmap) self.prev_bt.setIcon(prev_icon) # next next_icon = QIcon() next_pixmap = QPixmap('icons/next.png') next_icon.addPixmap(next_pixmap) self.next_bt.setIcon(next_icon) # play self.play_icon = QIcon() play_pixmap = QPixmap('icons/play.png') self.play_icon.addPixmap(play_pixmap) self.pause_icon = QIcon() pause_pixmap = QPixmap('icons/pause.png') self.pause_icon.addPixmap(pause_pixmap) self.play_pause_bt.setIcon(self.play_icon) # stop stop_icon = QIcon() stop_pixmap = QPixmap('icons/stop.png') stop_icon.addPixmap(stop_pixmap) self.stop_bt.setIcon(stop_icon) # search search_icon = QIcon() search_pixmap = QPixmap('icons/search2.png') search_icon.addPixmap(search_pixmap) self.go_bt.setIcon(search_icon) # table self.weekly_meals = {} self.stuff_table.cellClicked.connect(self.item_clicked) self.weekly_tw.cellClicked.connect(self.weekly_cell_clicked) # button calc self.calculate_bt.clicked.connect(self.calculate_cal) self.lcd_palette = self.calorie_lcd.palette() self.lcd_palette.setColor(self.lcd_palette.WindowText, QColor(102, 255, 102)) self.calorie_lcd.setPalette(self.lcd_palette) # radio buttons self.show_emp_rad.clicked.connect( lambda: self.radio_button_clicked(True, True)) self.show_rad.clicked.connect( lambda: self.radio_button_clicked(True, False)) self.cal_rad.clicked.connect( lambda: self.radio_button_clicked(True, None)) self.bought_rb.clicked.connect( lambda: self.radio_button_clicked(False, None)) # video stand_by_image = cv2.imread('src/default.png') self.update_frame(stand_by_image) #self.queue = queue.Queue() #self.capture_thread = threading.Thread(target=self.grab, args=(0, self.queue, stand_by_image)) #self.timer = QTimer(self) #self.timer.timeout.connect(self.update_frame) #self.timer.start(1) #global running #running = True #self.capture_thread.start() # language button self.language_bt.clicked.connect(self.toggle_language)
def __init__(self, obj=None): """Initialize task panel.""" self.form = Gui.PySideUic.loadUi(TASKPAGE) self.tabs = self.form.RenderTabs self.tabs.setCurrentIndex(0) self.layout = self.tabs.findChild(QFormLayout, "FieldsLayout") self.material_type_combo = self.form.findChild(QComboBox, "MaterialType") # Initialize material name combo self.material_combo = self.form.MaterialNameLayout.itemAt(0).widget() self.existing_materials = { obj.Label: obj for obj in App.ActiveDocument.Objects if is_valid_material(obj) } self.material_combo.addItems(list(self.existing_materials.keys())) self.material_combo.currentTextChanged.connect( self.on_material_name_changed) # Initialize material type combo # Note: itemAt(0) is label, itemAt(1) is combo self.material_type_combo = self.form.findChild(QComboBox, "MaterialType") material_type_set = [MaterialSettingsTaskPanel.NONE_MATERIAL_TYPE ] + list(STD_MATERIALS) self.material_type_combo.addItems(material_type_set) self.material_type_combo.currentTextChanged.connect( self.on_material_type_changed) self._set_layout_visible("FieldsLayout", False) self.fields = [] # Initialize Father layout self._set_layout_visible("FatherLayout", False) self.father_field = self.form.FatherLayout.itemAt(1).widget() # Initialize Passthru Renderers selector rdrwidget = self.form.findChild(QListWidget, "Renderers") for rdr in VALID_RENDERERS: item = QListWidgetItem() item.setText(rdr) item.setIcon(QIcon(os.path.join(ICONDIR, f"{rdr}.svg"))) rdrwidget.addItem(item) rdrwidget.setViewMode(QListView.IconMode) rdrwidget.setIconSize(QSize(48, 48)) rdrwidget.setMaximumWidth(96) rdrwidget.setSpacing(6) rdrwidget.setMovement(QListView.Static) rdrwidget.currentTextChanged.connect( self.on_passthrough_renderer_changed) self.passthru_rdr = rdrwidget self.passthru = self.form.findChild(QPlainTextEdit, "PassthroughEdit") self.passthru.textChanged.connect(self.on_passthrough_text_changed) self.passthru_cache = {} self._set_layout_visible("PassthruLayout", False) # Get selected material and initialize material type combo with it selection = {obj.Label for obj in Gui.Selection.getSelection()} selected_materials = selection & self.existing_materials.keys() try: selected_material = selected_materials.pop() except KeyError: pass else: self.material_combo.setCurrentText(selected_material)
def _initGUI(self): topHLayout = QHBoxLayout() hLayout = QHBoxLayout() vLayout = QVBoxLayout() # Label greeterText = QLabel("Welcome to <b>Pushup app</b>." + \ "<br><br> Select a profile:") vLayout.addWidget(greeterText) # List self.list = QListWidget() self.list.setMinimumWidth(150) self.list.setSelectionMode(QAbstractItemView.SingleSelection) # SingleSelection is the default value, but I prefer to be sure self.list.itemSelectionChanged.connect(self._activateButtons) for athlete in self.athletesList: iconW = QIcon.fromTheme("user-available") # doens't work on Mac and Windows # http://qt-project.org/doc/qt-4.8/qicon.html#fromTheme listW = QListWidgetItem(iconW, athlete._name) listW.setData(Qt.UserRole, athlete) self.list.addItem(listW) topHLayout.addWidget(self.list) self.profileWidget = ProfileFormWidget() self.profileWidget.hide() topHLayout.addWidget(self.profileWidget) vLayout.addLayout(topHLayout) vLayout.addLayout(hLayout) # Buttons self.okBtn = QPushButton("Ok") self.okBtn.setDisabled(True) self.okBtn.setDefault(True) self.okBtn.clicked.connect(self._okButtonSlot) self.list.itemDoubleClicked.connect(self._okButtonSlot) cancelBtn = QPushButton("Cancel") cancelBtn.clicked.connect(self._cancelButtonSlot) self.editBtn = QPushButton("Edit") self.editBtn.setDisabled(True) self.editBtn.setCheckable(True) self.editBtn.clicked.connect(self._toggleProfileEdit) self.saveBtn = QPushButton("Save changes") # Saves the changes made on the profile self.saveBtn.hide() self.saveBtn.clicked.connect(self._saveButtonSlot) self.removeProfileBtn = QPushButton("Remove Profile") self.removeProfileBtn.setDisabled(True) self.removeProfileBtn.clicked.connect(self._removeProfile_Dialog) hLayout.addWidget(self.editBtn) hLayout.addWidget(self.removeProfileBtn) hLayout.addWidget(cancelBtn) hLayout.addWidget(self.okBtn) hLayout.addWidget(self.saveBtn) self.setLayout(vLayout)