def __init__(self): loader = QUiLoader() dirname = os.path.dirname(os.path.abspath(__file__)) os.chdir(dirname) ui_file = QFile("dialog.ui") ui_file.open(QFile.ReadOnly) self.interface = loader.load(ui_file) self.interface.setWindowTitle('HMS-X Hameg Receiver Scanner ') self.wid = None ##handler da mini janelinha de calibrar self.mvr = None ##handler da mini janelinha de mover ui_file.close() super(janela, self).__init__()
def __init__(self, ui_file, parent=None): super(Form, self).__init__(parent) ui_file = QFile(ui_file) ui_file.open(QFile.ReadOnly) loader = QUiLoader() self.window = loader.load(ui_file) ui_file.close() btn = self.window.findChild(QPushButton, 'calculateButton') btn.clicked.connect(self.calculate_sum) self.window.show()
def __init__(self, ui_file, parent=None): super(MainWindow, self).__init__(parent) app = QApplication(sys.argv) ui_file = QFile(ui_file) ui_file.open(QFile.ReadOnly) loader = QUiLoader() self.window = loader.load(ui_file) ui_file.close() self.window.show() sys.exit(app.exec_())
def getJoinHelp(): ui_file = QFile(str(sessionVars.viewPath / "help.ui")) ui_file.open(QFile.ReadOnly) lder = QUiLoader() dlg = lder.load(ui_file) resUrl = QUrl(str(sessionVars.helpPath / 'signon.md')) dlg.help_text.setSource(resUrl) dlg.exec_()
def init(self) -> bool: """Create the Connection to the Database. For the Moment just SQLite Returns: Return true is the database successfull initialized. """ self.database = QSqlDatabase.database() if self.dbType == "sqlite": if not self.database.isValid(): self.database = QSqlDatabase.addDatabase("QSQLITE") if not self.database.isValid(): self.log.error("Cannot add database") return False self.database_name = self.__get_sqlite_name() file = QFile(self.database_name) if file.exists(): # When using the SQLite driver, open() will create the SQLite # database if it doesn't exist. self.log.info("Try open the existing db : {}".format( self.database_name)) self.database.setDatabaseName(self.database_name) else: self.database.setDatabaseName(self.database_name) self.log.info("Try create db : {}".format(self.database_name)) self.prepare_db() if not self.database.open(): self.log.error("Cannot open database") QFile.remove(self.database_name) return False elif self.dbType == "psql": self.database = QSqlDatabase.addDatabase("QPSQL") elif self.dbType == "odbc": self.database = QSqlDatabase.addDatabase("QODBC") self.database.setHostName(self.database_hostname) self.database.setPort(self.database_port) self.database.setUserName(self.database_user_name) self.database.setPassword(self.database_password) if not self.database.isValid(): self.log.error("Cannot add database") return False if not self.database.open(): self.log.error("Cannot open database") return False return True
def __init__(self): # 从文件中加载UI定义 qfile_query = QFile("../ui/query.ui") qfile_query.open(QFile.ReadOnly) qfile_query.close() # 从 UI 定义中动态 创建一个相应的窗口对象 # 注意:里面的控件对象也成为窗口对象的属性了 # 比如 self.ui.button , self.ui.textEdit self.ui = QUiLoader().load(qfile_query) self.ui.searchPushButton.clicked.connect(self.handleCalc)
def __init__(self, parent=None): super(InfoDialog, self).__init__(parent) ui_file_name = "ui/Ui_Dialog.ui" ui_file = QFile(ui_file_name) loader = QUiLoader() loader.registerCustomWidget(Dialog) self.ui = loader.load(ui_file) print(self.ui.__class__) ui_file.close()
def __init__(self, parent = None): super(HelloWorldDiag, self).__init__(parent) ui_file_name = "ui/hello_world.ui" ui_file = QFile(ui_file_name) loader = QUiLoader() self.wdDiag = loader.load(ui_file,self) ui_file.close() self.wdDiag.wdButtonHello.clicked.connect(self.SayHello) self.wdDiag.show()
def __init__(self): qfile = QFile("YYSCBGUI.ui") qfile.open(qfile.ReadOnly) qfile.close() self.cbgfunction = cbgreader.cbg() self.ui = QUiLoader().load(qfile) self.ui.Tojson.setEnabled(False) self.ui.Search.clicked.connect(self.search_button) self.ui.Delete.clicked.connect(self.delete_button) self.ui.Tojson.clicked.connect(self.tojson_button)
def testPhrase(self): #Test loading of quote.txt resource f = open(adjust_filename('quoteEnUS.txt', __file__), "r") orig = f.read() f.close() f = QFile(':/quote.txt') f.open(QIODevice.ReadOnly) #|QIODevice.Text) print("Error:", f.errorString()) copy = f.readAll() f.close() self.assertEqual(orig, copy)
def testImage(self): #Test loading of sample.png resource f = open(adjust_filename('sample.png', __file__), "rb") orig = f.read() f.close() f = QFile(':/sample.png') f.open(QIODevice.ReadOnly) copy = f.readAll() f.close() self.assertEqual(len(orig), len(copy)) self.assertEqual(orig, copy)
def save(self): outFile = QFile(self.backingStoragePath) if not outFile.open(QFile.WriteOnly | QFile.Text): outFile.close() return False stream = QTextStream(outFile) stream << self.contents outFile.close()
def __init__(self, url): self.ui_file_name = url self.ui_file = QFile(self.ui_file_name) if not self.ui_file.open( QIODevice.ReadOnly): # Error Occure if file not open print("Cannot open {}: {}".format(self.ui_file_name, ui_file.errorString())) sys.exit(-1) self.window = QUiLoader().load(self.ui_file) self.ui_file.close()
def __init__(self): # 从文件中加载UI定义 qfile_stats = QFile("ui/stats.ui") qfile_stats.open(QFile.ReadOnly) qfile_stats.close() # 从 UI 定义中动态 创建一个相应的窗口对象 # 注意:里面的控件对象也成为窗口对象的属性了 # 比如 self.ui.button , self.ui.textEdit self.ui = QUiLoader().load('ui/stats.ui') self.ui.button.clicked.connect(self.handleCalc)
def init(self): self.dir = mxs.getDir(mxs.name('publicExchangeStoreInstallPath')) ui_file = QFile( os.path.join(self.dir, 'AnimRef', 'Contents', 'interface', 'interface.ui')) ui_file.open(QFile.ReadOnly) self.ui = QUiLoader().load(ui_file, self) ui_file.close() layout = QtWidgets.QHBoxLayout() layout.addWidget(self.ui) layout.setMargin(4) self.setLayout(layout)
def openFile(self, path = ""): fileName = path if not fileName: fileName, _ = QFileDialog.getOpenFileName(self, self.tr("Open File"), "", "qmake Files (*.pro *.prf *.pri)") if fileName: inFile = QFile(fileName) if inFile.open(QFile.ReadOnly | QFile.Text): stream = QTextStream(inFile) self.editor.setPlainText(stream.readAll())
def load_ui(self): loader = QUiLoader() path = os.path.join(os.path.dirname(__file__), "ui/gui.ui") ui_file = QFile(path) ui_file.open(QFile.ReadOnly) self.window_calc = loader.load(ui_file, self) ui_file.close() icon_src = os.path.join(os.path.dirname(__file__), "data/duck-calc.png") icon = QtGui.QIcon() icon.addFile(icon_src) self.setWindowIcon(icon)
def populateUI(parent, filepath): ui_file = QFile(filepath) ui_file.open(QFile.ReadOnly) try: ui_loader = UiLoader(parent) ui_loader.registerCustomWidget(SequenceToolBox) ui_loader.registerCustomWidget(AutoResizingStackedWidget) ui_loader.registerCustomWidget(FileSelectionTreeWidget) ui_loader.registerCustomWidget(ColorButton) ui_loader.load(ui_file) finally: ui_file.close()
def __init__(self): # 从文件中加载UI定义 qfile = QFile("ui/cmos_sensitivity.ui") qfile.open(QFile.ReadOnly) qfile.close() # 从 UI 定义中动态 创建一个相应的窗口对象 # 注意:里面的控件对象也成为窗口对象的属性了 # 比如 self.ui.button , self.ui.textEdit self.ui = QUiLoader().load(qfile) # cmos_sensitivity button self.ui.pushButton_sensitivity_calculate.clicked.connect( self.handle_pushButton_sensitivity_calculate_clicked) self.ui.pushButton_sensitivity_image_illuminated.clicked.connect( self.handle_pushButton_sensitivity_image_illuminated_clicked) self.ui.pushButton_sensitivity_image_dark.clicked.connect( self.handle_pushButton_sensitivity_image_dark_clicked) # cmos_sensitivity lineEdit self.ui.lineEdit_sensitivity_width.setText('1920') self.ui.lineEdit_sensitivity_width.textChanged.connect( self.handle_lineEdit_sensitivity_width_change) self.ui.lineEdit_sensitivity_height.setText('1080') self.ui.lineEdit_sensitivity_height.textChanged.connect( self.handle_lineEdit_sensitivity_height_change) self.ui.lineEdit_sensitivity_widthpercent.setText('50') self.ui.lineEdit_sensitivity_widthpercent.textChanged.connect( self.handle_lineEdit_sensitivity_widthpercent_change) self.ui.lineEdit_sensitivity_heightpercent.setText('50') self.ui.lineEdit_sensitivity_heightpercent.textChanged.connect( self.handle_lineEdit_sensitivity_heightpercent_change) self.ui.lineEdit_sensitivity_bright.setText('200') self.ui.lineEdit_sensitivity_bright.textChanged.connect( self.handle_lineEdit_sensitivity_bright_change) self.ui.lineEdit_sensitivity_time_int.setText('30') self.ui.lineEdit_sensitivity_time_int.textChanged.connect( self.handle_lineEdit_sensitivity_time_int_change) # cmos_sensitivity comboBox self.ui.comboBox_sensitivity_sensorbit.currentIndexChanged.connect( self.handle_comboBox_sensitivity_sensorbit_change) self.ui.comboBox_sensitivity_sensorbit.addItems( ['12', '8', '16', '20']) self.ui.comboBox_sensitivity_cfa.currentIndexChanged.connect( self.handle_comboBox_sensitivity_cfa_change) self.ui.comboBox_sensitivity_cfa.addItems( ['rggb', 'bggr', 'gbrg', 'grbg', 'gray', 'color']) # cmos_sensitivity global variable self.filePath1 = "" self.filePath2 = ""
def __init__(self, ui_file, parent=None): super(MainWindow, self).__init__(parent) ui_file = QFile(ui_file) ui_file.open(QFile.ReadOnly) loader = QUiLoader() self.window = loader.load(ui_file) ui_file.close() dir_btn: QPushButton = self.window.findChild(QPushButton, "dir_choose_btn") dir_btn.clicked.connect(self.dir_btn_handler) self.dirPath: QLineEdit = self.window.findChild(QLineEdit, "dirPath") self.repeatFiles_dir: QLineEdit = self.window.findChild( QLineEdit, "repeatFiles_dir") self.singleFiles_dir: QLineEdit = self.window.findChild( QLineEdit, "singleFiles_dir") self.moveSingleFiles: QCheckBox = self.window.findChild( QCheckBox, "moveSingleFiles") self.moveRepeatFiles: QCheckBox = self.window.findChild( QCheckBox, "moveRepeatFiles") self.sortBar: QProgressBar = self.window.findChild( QProgressBar, "sortBar") self.sortBar.setValue(0) self.moveBar: QProgressBar = self.window.findChild( QProgressBar, "moveBar") self.moveBar.setValue(0) self.startButton: QPushButton = self.window.findChild( QPushButton, "startButton") self.startButton.clicked.connect(self.start_handler) self.stopButton: QPushButton = self.window.findChild( QPushButton, "stopButton") self.stopButton.clicked.connect(self.stop_handler) self.worker: Worker = None self.running = False self.thread_pool = QThreadPool() print("Multi threading with maximum %d threads" % self.thread_pool.maxThreadCount()) self.msg_box = QMessageBox(parent=self.window) self.msg_box.setIcon(QMessageBox.Critical) self.msg_box.setWindowTitle("Некорректные настройки") self.window.destroyed.connect(self.stop_handler) self.window.show()
def __init__(self): self.app = QApplication([]) self.qFile = QFile("端口扫描工具.ui") self.qFile.open(QFile.ReadOnly) self.ui = QUiLoader().load(self.qFile) self.qFile.close() self.ui.scan.clicked.connect(self.play) self.ui.clear.clicked.connect(self.clear) self.ui.ip.setPlaceholderText("默认:127.0.0.1") self.ui.startPort.setPlaceholderText("默认为:0") self.ui.endPort.setPlaceholderText("默认为:65355")
def createNewNote(self, name): outFileName = name + ".md" backingFileName = self.localStoragePath + "/" + outFileName outFile = QFile(backingFileName) outFile.open(QFile.NewOnly | QFile.Text) outFile.close() note = Note(name, backingFileName) note.save() self.allNotes.append(note) return note
def __init__(self, ui_file, parent=None): super(DiceRoller, self).__init__(parent) #load ui file ui_file = QFile(ui_file) ui_file.open(QFile.ReadOnly) loader = QUiLoader() self.window = loader.load(ui_file) ui_file.close() #startup self.plotter = Plotter(parent=self) self.window.mainLayout.addWidget(self.plotter) self.setup_ui() self.window.show()
def loadscreen(self): guiname = "gui/SECURITY.ui" try: ui_file = QFile(guiname) ui_file.open(QFile.ReadOnly) loader = QUiLoader() self.window = loader.load(ui_file) ui_file.close() #self.window.show() self.log.debug('Loading screen:'.format(guiname)) except FileNotFoundError: self.log.debug( "Could not find {}".format(guiname)) # CATCHES EXIT SHUTDOWN
def load(cls, form: str) -> QWidget: """ Load up a .ui file and return it. :param form: The name of the .ui file to load, without the .ui extension :return: The QWidget created from the UI file """ ui_path = str(cls.path / f"forms/designer/{form}.ui") ui_file = QFile(ui_path) ui_file.open(QFile.ReadOnly) return cls.loader.load(ui_file)
def __init__(self, msg): QWidget.__init__(self) ui_file = QFile('msg_box.ui') ui_file.open(QFile.ReadOnly) loader = QUiLoader() self.ui = loader.load(ui_file, self) self.setFixedSize(400, 300) ui_file.close() self.ui.msg_label.setText(msg) self.ui.exclamation_label.setPixmap(QPixmap('images/exclamation_red.png')) self.setWindowTitle('msg') self.setWindowIcon(QIcon('images/logo.png')) self.ui.close_button.clicked.connect(self.close_widget)
def load_ui(self): loader = QUiLoader() path = os.path.join(os.path.dirname(__file__), "form.ui") ui_file = QFile(path) ui_file.open(QFile.ReadOnly) global xx xx = loader.load(ui_file, self) xx.btn.clicked.connect(say_hello) xx.label.setText('abc') ui_file.close()
def loadUiWidget(uifilename, parent=None, customWidgets=[]): uifilename = os.path.join(file_dir, uifilename) loader = QUiLoader() for widget in customWidgets: loader.registerCustomWidget(widget) uifile = QFile(uifilename) uifile.open(QFile.ReadOnly) ui = loader.load(uifile, parent) uifile.close() return ui
def create_player(self, parent, summoner): loader = QUiLoader() file = QFile("UI/ui_playerpoolwidget.ui") file.open(QFile.ReadOnly) new_player = loader.load(file, parent) file.close() # Set the QWidget's summoner new_player.summoner = summoner return new_player
def __init__(self, fileName): self.app = QApplication([]) # 4.创建一个应用对象 self.qFile = QFile(fileName) # 5.获取 UI 文件 self.qFile.open(QFile.ReadOnly) # 6.打开 UI 文件 self.ui = QUiLoader().load(self.qFile) # 7.加载 UI 对象 self.qFile.close() # 8.关闭 UI 文件 self.ui.method.addItems(['GIT', 'POST', 'PUT', 'DELETE']) self.ui.endOut.clicked.connect(self.request) self.ui.clear.clicked.connect(self.clear) self.ui.copy.clicked.connect(self.copy)