Python PySide2.QtWidgets.QPushButton() Examples
The following are 30
code examples of PySide2.QtWidgets.QPushButton().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PySide2.QtWidgets
, or try the search function
.
Example #1
Source File: button_and_long_process.py From Hands-On-Blockchain-for-Python-Developers with MIT License | 6 votes |
def __init__(self): super(ButtonAndLongProcess, self).__init__() self.button = QPushButton("button") self.button.clicked.connect(self.buttonClicked) self.label = QLabel("label: before clicked") layout = QVBoxLayout() layout.addWidget(self.button) layout.addWidget(self.label) self.setLayout(layout) self.long_process_thread = LongProcessThread() self.long_process_thread.transaction.connect(self.afterLongProcess)
Example #2
Source File: UITranslator.py From universal_tool_template.py with MIT License | 6 votes |
def setLang(self, langName): uiList_lang_read = self.memoData['lang'][langName] for ui_name in uiList_lang_read: ui_element = self.uiList[ui_name] if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]: # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox if uiList_lang_read[ui_name] != "": ui_element.setText(uiList_lang_read[ui_name]) elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]: # uiType: QMenu, QGroupBox if uiList_lang_read[ui_name] != "": ui_element.setTitle(uiList_lang_read[ui_name]) elif type(ui_element) in [ QtWidgets.QTabWidget]: # uiType: QTabWidget tabCnt = ui_element.count() if uiList_lang_read[ui_name] != "": tabNameList = uiList_lang_read[ui_name].split(';') if len(tabNameList) == tabCnt: for i in range(tabCnt): if tabNameList[i] != "": ui_element.setTabText(i,tabNameList[i]) elif type(ui_element) == str: # uiType: string for msg if uiList_lang_read[ui_name] != "": self.uiList[ui_name] = uiList_lang_read[ui_name]
Example #3
Source File: MyWindow_ui.py From MayaDev with MIT License | 6 votes |
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(300, 150) self.verticalLayout = QtWidgets.QVBoxLayout(Form) self.verticalLayout.setObjectName("verticalLayout") self.btnCreateSphere = QtWidgets.QPushButton(Form) self.btnCreateSphere.setObjectName("btnCreateSphere") self.verticalLayout.addWidget(self.btnCreateSphere) self.btnCallCppPlugin = QtWidgets.QPushButton(Form) self.btnCallCppPlugin.setObjectName("btnCallCppPlugin") self.verticalLayout.addWidget(self.btnCallCppPlugin) self.btnCallCSPlugin = QtWidgets.QPushButton(Form) self.btnCallCSPlugin.setObjectName("btnCallCSPlugin") self.verticalLayout.addWidget(self.btnCallCSPlugin) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
Example #4
Source File: twitter_dapp.py From Hands-On-Blockchain-for-Python-Developers with MIT License | 6 votes |
def createTweetsGroupBox(self): self.tweets_group_box = QtWidgets.QGroupBox("Tweets") self.account_address = QtWidgets.QLineEdit() self.fetch_button = QtWidgets.QPushButton("Fetch") self.add_to_bookmark_button = QtWidgets.QPushButton("Bookmark it!") self.connect(self.fetch_button, QtCore.SIGNAL('clicked()'), self.fetchTweets) self.connect(self.add_to_bookmark_button, QtCore.SIGNAL('clicked()'), self.bookmarkAddress) account_address_layout = QtWidgets.QHBoxLayout() account_address_layout.addWidget(self.account_address) account_address_layout.addWidget(self.fetch_button) account_address_layout.addWidget(self.add_to_bookmark_button) self.tweets_layout = QtWidgets.QVBoxLayout() self.tweets_main_layout = QtWidgets.QVBoxLayout() self.tweets_main_layout.addWidget(QtWidgets.QLabel("Address:")) self.tweets_main_layout.addLayout(account_address_layout) self.tweets_main_layout.addSpacing(20) self.tweets_main_layout.addLayout(self.tweets_layout) self.tweets_group_box.setLayout(self.tweets_main_layout)
Example #5
Source File: button_with_sizepolicy.py From Hands-On-Blockchain-for-Python-Developers with MIT License | 6 votes |
def __init__(self): super(ButtonWithSizePolicy, self).__init__() button1 = QPushButton("button default") button2 = QPushButton("button maximum") button2.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) button3 = QPushButton("button preferred") button3.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) button4 = QPushButton("button expanding") button4.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) button5 = QPushButton("button minimum") button5.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) button6 = QPushButton("button minimum expanding") button6.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) layout = QVBoxLayout() layout.addWidget(button1) layout.addWidget(button2) layout.addWidget(button3) layout.addWidget(button4) layout.addWidget(button5) layout.addWidget(button6) self.setLayout(layout)
Example #6
Source File: dialog.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def __init__(self, command, parent=None): super(CommandDisplayDialog, self).__init__(parent) self.setWindowTitle("Command") self.text = QtWidgets.QTextEdit() self.text.setReadOnly(True) self.text.setPlainText(command) self.ok = QtWidgets.QPushButton('ok') self.ok.released.connect(self.accept) self.button_layout = QtWidgets.QHBoxLayout() self.button_layout.setContentsMargins(0, 0, 0, 0) self.button_layout.addStretch(1) self.button_layout.addWidget(self.ok) self.layout = QtWidgets.QVBoxLayout(self) self.layout.addWidget(self.text) self.layout.addLayout(self.button_layout)
Example #7
Source File: universal_tool_template_2010.py From universal_tool_template.py with MIT License | 6 votes |
def setLang(self, langName): lang_data = self.memoData['lang'][langName] for ui_name in lang_data.keys(): if ui_name in self.uiList.keys() and lang_data[ui_name] != '': ui_element = self.uiList[ui_name] # '' means no translation availdanle in that data file if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ): # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox ui_element.setText(lang_data[ui_name]) elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ): # uiType: QMenu, QGroupBox ui_element.setTitle(lang_data[ui_name]) elif isinstance(ui_element, QtWidgets.QTabWidget): # uiType: QTabWidget tabCnt = ui_element.count() tabNameList = lang_data[ui_name].split(';') if len(tabNameList) == tabCnt: for i in range(tabCnt): if tabNameList[i] != '': ui_element.setTabText(i,tabNameList[i]) elif isinstance(ui_element, QtWidgets.QComboBox): # uiType: QComboBox itemCnt = ui_element.count() itemNameList = lang_data[ui_name].split(';') ui_element.clear() ui_element.addItems(itemNameList) elif isinstance(ui_element, QtWidgets.QTreeWidget): # uiType: QTreeWidget labelCnt = ui_element.headerItem().columnCount() labelList = lang_data[ui_name].split(';') ui_element.setHeaderLabels(labelList) elif isinstance(ui_element, QtWidgets.QTableWidget): # uiType: QTableWidget colCnt = ui_element.columnCount() headerList = lang_data[ui_name].split(';') cur_table.setHorizontalHeaderLabels( headerList ) elif isinstance(ui_element, (str, unicode) ): # uiType: string for msg self.uiList[ui_name] = lang_data[ui_name]
Example #8
Source File: widgets.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def __init__(self, parent=None): super(ColorEdit, self).__init__(parent) self.text = QtWidgets.QLineEdit() self.text.returnPressed.connect(self.apply) self.button = QtWidgets.QPushButton(icon('picker.png'), '') self.button.setFixedSize(21, 21) self.button.released.connect(self.pick_color) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.addWidget(self.text) self.layout.addWidget(self.button) self._value = self.value()
Example #9
Source File: widgets.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def __init__(self, parent=None): super(BrowseEdit, self).__init__(parent) self.text = QtWidgets.QLineEdit() self.text.returnPressed.connect(self.apply) self.button = QtWidgets.QPushButton('B') self.button.setFixedSize(21, 21) self.button.released.connect(self.browse) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.addWidget(self.text) self.layout.addWidget(self.button) self._value = self.value()
Example #10
Source File: universal_tool_template_1110.py From universal_tool_template.py with MIT License | 5 votes |
def fontDown_action(self): if self.memoData['font_size'] >= self.memoData['font_size_default']: self.memoData['font_size'] -= 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #11
Source File: universal_tool_template_1100.py From universal_tool_template.py with MIT License | 5 votes |
def fontUp_action(self): self.memoData['font_size'] += 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #12
Source File: universal_tool_template_1115.py From universal_tool_template.py with MIT License | 5 votes |
def fontDown_action(self): if self.memoData['font_size'] >= self.memoData['font_size_default']: self.memoData['font_size'] -= 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #13
Source File: universal_tool_template_1100.py From universal_tool_template.py with MIT License | 5 votes |
def fontDown_action(self): if self.memoData['font_size'] >= self.memoData['font_size_default']: self.memoData['font_size'] -= 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #14
Source File: universal_tool_template_1100.py From universal_tool_template.py with MIT License | 5 votes |
def setLang(self, langName): lang_data = self.memoData['lang'][langName] for ui_name in lang_data.keys(): if ui_name in self.uiList.keys() and lang_data[ui_name] != '': ui_element = self.uiList[ui_name] # '' means no translation availdanle in that data file if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ): # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox ui_element.setText(lang_data[ui_name]) elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ): # uiType: QMenu, QGroupBox ui_element.setTitle(lang_data[ui_name]) elif isinstance(ui_element, QtWidgets.QTabWidget): # uiType: QTabWidget tabCnt = ui_element.count() tabNameList = lang_data[ui_name].split(';') if len(tabNameList) == tabCnt: for i in range(tabCnt): if tabNameList[i] != '': ui_element.setTabText(i,tabNameList[i]) elif isinstance(ui_element, QtWidgets.QComboBox): # uiType: QComboBox itemCnt = ui_element.count() itemNameList = lang_data[ui_name].split(';') ui_element.clear() ui_element.addItems(itemNameList) elif isinstance(ui_element, QtWidgets.QTreeWidget): # uiType: QTreeWidget labelCnt = ui_element.headerItem().columnCount() labelList = lang_data[ui_name].split(';') ui_element.setHeaderLabels(labelList) elif isinstance(ui_element, QtWidgets.QTableWidget): # uiType: QTableWidget colCnt = ui_element.columnCount() headerList = lang_data[ui_name].split(';') cur_table.setHorizontalHeaderLabels( headerList ) elif isinstance(ui_element, (str, unicode) ): # uiType: string for msg self.uiList[ui_name] = lang_data[ui_name]
Example #15
Source File: universal_tool_template_1110.py From universal_tool_template.py with MIT License | 5 votes |
def fontUp_action(self): self.memoData['font_size'] += 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #16
Source File: universal_tool_template_1110.py From universal_tool_template.py with MIT License | 5 votes |
def setLang(self, langName): lang_data = self.memoData['lang'][langName] for ui_name in lang_data.keys(): if ui_name in self.uiList.keys() and lang_data[ui_name] != '': ui_element = self.uiList[ui_name] # '' means no translation availdanle in that data file if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ): # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox ui_element.setText(lang_data[ui_name]) elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ): # uiType: QMenu, QGroupBox ui_element.setTitle(lang_data[ui_name]) elif isinstance(ui_element, QtWidgets.QTabWidget): # uiType: QTabWidget tabCnt = ui_element.count() tabNameList = lang_data[ui_name].split(';') if len(tabNameList) == tabCnt: for i in range(tabCnt): if tabNameList[i] != '': ui_element.setTabText(i,tabNameList[i]) elif isinstance(ui_element, QtWidgets.QComboBox): # uiType: QComboBox itemCnt = ui_element.count() itemNameList = lang_data[ui_name].split(';') ui_element.clear() ui_element.addItems(itemNameList) elif isinstance(ui_element, QtWidgets.QTreeWidget): # uiType: QTreeWidget labelCnt = ui_element.headerItem().columnCount() labelList = lang_data[ui_name].split(';') ui_element.setHeaderLabels(labelList) elif isinstance(ui_element, QtWidgets.QTableWidget): # uiType: QTableWidget colCnt = ui_element.columnCount() headerList = lang_data[ui_name].split(';') cur_table.setHorizontalHeaderLabels( headerList ) elif isinstance(ui_element, (str, unicode) ): # uiType: string for msg self.uiList[ui_name] = lang_data[ui_name]
Example #17
Source File: universal_tool_template_1112.py From universal_tool_template.py with MIT License | 5 votes |
def setLang(self, langName): lang_data = self.memoData['lang'][langName] for ui_name in lang_data.keys(): if ui_name in self.uiList.keys() and lang_data[ui_name] != '': ui_element = self.uiList[ui_name] # '' means no translation availdanle in that data file if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ): # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox ui_element.setText(lang_data[ui_name]) elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ): # uiType: QMenu, QGroupBox ui_element.setTitle(lang_data[ui_name]) elif isinstance(ui_element, QtWidgets.QTabWidget): # uiType: QTabWidget tabCnt = ui_element.count() tabNameList = lang_data[ui_name].split(';') if len(tabNameList) == tabCnt: for i in range(tabCnt): if tabNameList[i] != '': ui_element.setTabText(i,tabNameList[i]) elif isinstance(ui_element, QtWidgets.QComboBox): # uiType: QComboBox itemCnt = ui_element.count() itemNameList = lang_data[ui_name].split(';') ui_element.clear() ui_element.addItems(itemNameList) elif isinstance(ui_element, QtWidgets.QTreeWidget): # uiType: QTreeWidget labelCnt = ui_element.headerItem().columnCount() labelList = lang_data[ui_name].split(';') ui_element.setHeaderLabels(labelList) elif isinstance(ui_element, QtWidgets.QTableWidget): # uiType: QTableWidget colCnt = ui_element.columnCount() headerList = lang_data[ui_name].split(';') cur_table.setHorizontalHeaderLabels( headerList ) elif isinstance(ui_element, (str, unicode) ): # uiType: string for msg self.uiList[ui_name] = lang_data[ui_name]
Example #18
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 5 votes |
def qui(self, ui_list_string, parentObject_string='', opt=''): # pre-defined user short name syntax type_dict = { 'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout', 'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget', 'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox', 'txt': 'QTextEdit', 'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget', 'space': 'QSpacerItem', } # get ui_list, creation or existing ui object ui_list = [x.strip() for x in ui_list_string.split('|')] for i in range(len(ui_list)): if ui_list[i] in self.uiList: # - exisiting object ui_list[i] = self.uiList[ui_list[i]] else: # - string creation: # get part info partInfo = ui_list[i].split(';',1) uiName = partInfo[0].split('@')[0] uiType = uiName.rsplit('_',1)[-1] if uiType in type_dict: uiType = type_dict[uiType] # set quickUI string format ui_list[i] = partInfo[0]+';'+uiType if len(partInfo)==1: # give empty button and label a place holder name if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'): ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName elif len(partInfo)==2: ui_list[i]=ui_list[i]+";"+partInfo[1] # get parentObject or exisiting object parentObject = parentObject_string if parentObject in self.uiList: parentObject = self.uiList[parentObject] # process quickUI self.quickUI(ui_list, parentObject, opt)
Example #19
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 5 votes |
def setLang(self, langName): uiList_lang_read = self.memoData['lang'][langName] for ui_name in uiList_lang_read: ui_element = self.uiList[ui_name] if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]: # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox if uiList_lang_read[ui_name] != "": ui_element.setText(uiList_lang_read[ui_name]) elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]: # uiType: QMenu, QGroupBox if uiList_lang_read[ui_name] != "": ui_element.setTitle(uiList_lang_read[ui_name]) elif type(ui_element) in [ QtWidgets.QTabWidget]: # uiType: QTabWidget tabCnt = ui_element.count() if uiList_lang_read[ui_name] != "": tabNameList = uiList_lang_read[ui_name].split(';') if len(tabNameList) == tabCnt: for i in range(tabCnt): if tabNameList[i] != "": ui_element.setTabText(i,tabNameList[i]) elif type(ui_element) == str: # uiType: string for msg if uiList_lang_read[ui_name] != "": self.uiList[ui_name] = uiList_lang_read[ui_name]
Example #20
Source File: universal_tool_template_2010.py From universal_tool_template.py with MIT License | 5 votes |
def fontNormal_action(self, uiClass_list=[]): if len(uiClass_list) == 0: uiClass_list = 'QLabel,QPushButton'.split(',') self.memoData['font_size'] = self.memoData['font_size_default'] self.setStyleSheet( "{0} { font-size: {1}pt;}".format(','.join(uiClass_list), self.memoData['font_size']) )
Example #21
Source File: UITranslator.py From universal_tool_template.py with MIT License | 5 votes |
def loadLang(self): self.quickMenu(['language_menu;&Language']) cur_menu = self.uiList['language_menu'] self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu) cur_menu.addSeparator() self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default')) # store default language self.memoData['lang']={} self.memoData['lang']['default']={} for ui_name in self.uiList: ui_element = self.uiList[ui_name] if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]: # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox self.memoData['lang']['default'][ui_name] = str(ui_element.text()) elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]: # uiType: QMenu, QGroupBox self.memoData['lang']['default'][ui_name] = str(ui_element.title()) elif type(ui_element) in [ QtWidgets.QTabWidget]: # uiType: QTabWidget tabCnt = ui_element.count() tabNameList = [] for i in range(tabCnt): tabNameList.append(str(ui_element.tabText(i))) self.memoData['lang']['default'][ui_name]=';'.join(tabNameList) elif type(ui_element) == str: # uiType: string for msg self.memoData['lang']['default'][ui_name] = self.uiList[ui_name] # try load other language lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__)) baseName = os.path.splitext( os.path.basename(self.location) )[0] for fileName in os.listdir(lang_path): if fileName.startswith(baseName+"_lang_"): langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","") self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) ) self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu) self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName)) # if no language file detected, add export default language option if len(self.memoData['lang']) == 1: self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu) self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
Example #22
Source File: UITranslator.py From universal_tool_template.py with MIT License | 5 votes |
def qui(self, ui_list_string, parentObject_string='', opt=''): # pre-defined user short name syntax type_dict = { 'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout', 'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget', 'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox', 'txtEdit': 'LNTextEdit', 'txt': 'QTextEdit', 'tree': 'QTreeWidget', 'table': 'QTableWidget', 'space': 'QSpacerItem', } # get ui_list, creation or existing ui object ui_list = [x.strip() for x in ui_list_string.split('|')] for i in range(len(ui_list)): if ui_list[i] in self.uiList: # - exisiting object ui_list[i] = self.uiList[ui_list[i]] else: # - string creation: # get part info partInfo = ui_list[i].split(';',1) uiName = partInfo[0].split('@')[0] uiType = uiName.rsplit('_',1)[-1] if uiType in type_dict: uiType = type_dict[uiType] # set quickUI string format ui_list[i] = partInfo[0]+';'+uiType if len(partInfo)==1: # give empty button and label a place holder name if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'): ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName elif len(partInfo)==2: ui_list[i]=ui_list[i]+";"+partInfo[1] # get parentObject or exisiting object parentObject = parentObject_string if parentObject in self.uiList: parentObject = self.uiList[parentObject] # process quickUI self.quickUI(ui_list, parentObject, opt)
Example #23
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 5 votes |
def setupUI(self): super(self.__class__,self).setupUI() #------------------------------ # user ui creation part #------------------------------ # + template: qui version since universal tool template v7 # - no extra variable name, all text based creation and reference self.qui('source_txt | process_btn;Process and Update', 'upper_vbox') self.qui('upper_vbox | result_txt', 'input_split;v') self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox') self.qui('input_split | fileBtn_layout', 'main_layout') # - template : quickUI version since universal tool template v6 ''' upper_layout = self.quickUI(["source_txt;QTextEdit","process_btn;QPushButton;Process and Update"],"upper_QVBoxLayout") upper_layout.setContentsMargins(0,0,0,0) input_split = self.quickSplitUI("input_split", [ upper_layout, self.quickUI(["result_txt;QTextEdit"])[0] ], "v") fileBtn_layout = self.quickUI(["filePath_input;QLineEdit", "fileLoad_btn;QPushButton;Load", "fileExport_btn;QPushButton;Export"],"fileBtn_QHBoxLayout") self.quickUI([input_split, fileBtn_layout], main_layout) ''' # - template : invisible but functional button ''' self.uiList['secret_btn'] = QtWidgets.QPushButton(self) self.uiList['secret_btn'].setText("") self.uiList['secret_btn'].setGeometry(0, 0, 50, 20) self.uiList['secret_btn'].setStyleSheet("QPushButton{background-color: rgba(0, 0, 0,0);} QPushButton:pressed{background-color: rgba(0, 0, 0,0); border: 0px;} QPushButton:hover{background-color: rgba(0, 0, 0,0); border: 0px;}") #:hover:pressed:focus:hover:disabled ''' #------------- end ui creation -------------------- keep_margin_layout = ['main_layout'] for name, each in self.uiList.items(): if isinstance(each, QtWidgets.QLayout) and name not in keep_margin_layout and not name.endswith('_grp_layout'): each.setContentsMargins(0, 0, 0, 0) self.quickInfo('Ready')
Example #24
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def fontDown_action(self): if self.memoData['font_size'] >= self.memoData['font_size_default']: self.memoData['font_size'] -= 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #25
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def fontUp_action(self): self.memoData['font_size'] += 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #26
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 5 votes |
def fontNormal_action(self): self.memoData['font_size'] = self.memoData['font_size_default'] self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])
Example #27
Source File: universal_tool_template_0803.py From universal_tool_template.py with MIT License | 5 votes |
def qui(self, ui_list_string, parentObject_string='', opt=''): # pre-defined user short name syntax type_dict = { 'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout', 'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget', 'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox', 'txt': 'QTextEdit', 'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget', 'space': 'QSpacerItem', } # get ui_list, creation or existing ui object ui_list = [x.strip() for x in ui_list_string.split('|')] for i in range(len(ui_list)): if ui_list[i] in self.uiList: # - exisiting object ui_list[i] = self.uiList[ui_list[i]] else: # - string creation: # get part info partInfo = ui_list[i].split(';',1) uiName = partInfo[0].split('@')[0] uiType = uiName.rsplit('_',1)[-1] if uiType in type_dict: uiType = type_dict[uiType] # set quickUI string format ui_list[i] = partInfo[0]+';'+uiType if len(partInfo)==1: # give empty button and label a place holder name if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'): ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName elif len(partInfo)==2: ui_list[i]=ui_list[i]+";"+partInfo[1] # get parentObject or exisiting object parentObject = parentObject_string if parentObject in self.uiList: parentObject = self.uiList[parentObject] # process quickUI self.quickUI(ui_list, parentObject, opt)
Example #28
Source File: universal_tool_template_2010.py From universal_tool_template.py with MIT License | 5 votes |
def fontDown_action(self, uiClass_list=[]): if len(uiClass_list) == 0: uiClass_list = 'QLabel,QPushButton'.split(',') if self.memoData['font_size'] >= self.memoData['font_size_default']: self.memoData['font_size'] -= 2 self.setStyleSheet( "{0} { font-size: {1}pt;}".format(','.join(uiClass_list), self.memoData['font_size']) )
Example #29
Source File: universal_tool_template_2010.py From universal_tool_template.py with MIT License | 5 votes |
def fontUp_action(self, uiClass_list=[]): if len(uiClass_list) == 0: uiClass_list = 'QLabel,QPushButton'.split(',') self.memoData['font_size'] += 2 self.setStyleSheet( "{0} { font-size: {1}pt;}".format(','.join(uiClass_list), self.memoData['font_size']) )
Example #30
Source File: universal_tool_template_1020.py From universal_tool_template.py with MIT License | 5 votes |
def fontUp_action(self): self.memoData['font_size'] += 2 self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])