def main(): """Main entry of program. Initializes logging, database access, the Qt framework, and displays the main window to the user. .. todo:: Instead of adding each series sequentially, the model could be expanded with a method to add multiple series, which could speed up the application's start. """ _init_logging() app = QApplication(sys.argv) splash_screen = SplashScreen() splash_screen.showMessage("Initializing database") db_init() splash_screen.showMessage("Loading Series") window = MainWindow() for series in db_get_series(): splash_screen.showMessage("Loading {}".format(series.series_name)) window.model.add_item(series) window.show() splash_screen.finish(window) sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) window = MainWindow() window.showMaximized() return app.exec_()
class Browser(QObject): # pylint: disable=too-many-public-methods __execute_script_called = Signal(str) def __init__(self): super().__init__() self.app = QApplication([]) self.webview = QWebView() self.webview.setAttribute(Qt.WA_DeleteOnClose) self.webview.destroyed.connect(self.app.quit) self.__execute_script_called.connect(self.__execute_script) def __execute_script(self, javascript_code: str): assert current_thread_is_main() self.webview.page().mainFrame().evaluateJavaScript(javascript_code) def execute_script(self, javascript_code: str): if current_thread_is_main(): self.__execute_script(javascript_code) else: self.__execute_script_called.emit(javascript_code) def run(self, url): assert current_thread_is_main() self.webview.showFullScreen() self.webview.load(url) self.app.exec_()
def main(): app= QApplication(argv) window= Window(appPath) window.show() status= app.exec_() sys.exit(status)
def calculixFinished(self, exitCode): print "calculixFinished()", exitCode print self.Calculix.state() # Restore previous cwd QtCore.QDir.setCurrent(self.cwd) self.printCalculiXstdout() self.Timer.stop() self.femConsoleMessage("Calculix done!", "#00AA00") self.form.pushButton_generate.setText("Re-run Calculix") print "Loading results...." self.femConsoleMessage("Loading result sets...") self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) fea = FemTools() fea.reset_all() frd_result_file = os.path.splitext(self.inp_file_name)[0] + '.frd' if os.path.isfile(frd_result_file): QApplication.setOverrideCursor(Qt.WaitCursor) ccxFrdReader.importFrd(frd_result_file, FemGui.getActiveAnalysis()) QApplication.restoreOverrideCursor() self.femConsoleMessage("Loading results done!", "#00AA00") else: self.femConsoleMessage("Loading results failed! Results file doesn\'t exist", "#FF0000") self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
def calculate(self): FreeCAD.FEM_dialog["results_type"] = "None" self.update() self.restore_result_dialog() # Convert existing values to numpy array P1 = np.array(self.result_object.PrincipalMax) P2 = np.array(self.result_object.PrincipalMed) P3 = np.array(self.result_object.PrincipalMin) Von = np.array(self.result_object.StressValues) T = np.array(self.result_object.Temperature) dispvectors = np.array(self.result_object.DisplacementVectors) x = np.array(dispvectors[:, 0]) y = np.array(dispvectors[:, 1]) z = np.array(dispvectors[:, 2]) userdefined_eq = x + y + z + T + Von + P1 + P2 + P3 # Dummy equation to get around flake8, varibles not being used userdefined_eq = self.form.user_def_eq.toPlainText() # Get equation to be used UserDefinedFormula = eval(userdefined_eq).tolist() minm = min(UserDefinedFormula) avg = sum(UserDefinedFormula) / len(UserDefinedFormula) maxm = max(UserDefinedFormula) QApplication.setOverrideCursor(Qt.WaitCursor) if self.suitable_results: self.MeshObject.ViewObject.setNodeColorByScalars(self.result_object.NodeNumbers, UserDefinedFormula) self.set_result_stats("", minm, avg, maxm) QtGui.qApp.restoreOverrideCursor()
def copy_to_clipboard(plot): # pass # @staticmethod # def wx_copy_to_clipboard(plot): # # WX specific, though QT implementation is similar using # # QImage and QClipboard # import wx # width, height = plot.outer_bounds # gc = PlotGraphicsContext((width, height), dpi=72) backbuffer = plot.use_backbuffer plot.use_backbuffer = False gc.render_component(plot) plot.use_backbuffer = backbuffer # # # Create a bitmap the same size as the plot # # and copy the plot data to it bmp = gc.bmp_array if gc.format().startswith('bgra'): bmp_rgba = bmp[:,:,[2,1,0,3]] else: bmp_rgba = bmp bitmap=QImage(bmp_rgba.tostring(),width,height, PySide.QtGui.QImage.Format_RGB32) if QApplication.clipboard(): QApplication.clipboard().setImage(bitmap.copy()) else: PySide.QtGui.QMessageBox("Unable to open the clipboard.", "Error")
def typeChanged(self, index): selected = self.form.comboBox_Type.itemData(index) if selected[0] == "None": self.MeshObject.ViewObject.NodeColor = {} self.MeshObject.ViewObject.ElementColor = {} self.form.lineEdit_Max.setProperty("unit", "mm") self.form.lineEdit_Max.setText(" 0 mm") self.form.lineEdit_Min.setProperty("unit", "mm") self.form.lineEdit_Min.setText(" 0 mm") self.form.lineEdit_Avg.setProperty("unit", "mm") self.form.lineEdit_Avg.setText(" 0 mm") return QApplication.setOverrideCursor(Qt.WaitCursor) if self.DisplacementObject: if selected[0] in ("U1", "U2", "U3", "Uabs"): (minm, maxm, avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject, selected[1]) unit = "mm" if self.StressObject: if selected[0] in ("Sabs"): (minm, maxm, avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.StressObject) unit = "MPa" self.form.lineEdit_Max.setProperty("unit", unit) self.form.lineEdit_Max.setText("{:.6} {}".format(maxm, unit)) self.form.lineEdit_Min.setProperty("unit", unit) self.form.lineEdit_Min.setText("{:.6} {}".format(minm, unit)) self.form.lineEdit_Avg.setProperty("unit", unit) self.form.lineEdit_Avg.setText("{:.6} {}".format(avg, unit)) QtGui.qApp.restoreOverrideCursor()
def vm_stress_selected(self, state): FreeCAD.FEM_dialog["results_type"] = "Sabs" QApplication.setOverrideCursor(Qt.WaitCursor) self.MeshObject.ViewObject.setNodeColorByScalars(self.result_object.ElementNumbers, self.result_object.StressValues) (minm, avg, maxm) = self.get_result_stats("Sabs") self.set_result_stats("MPa", minm, avg, maxm) QtGui.qApp.restoreOverrideCursor()
def main(argv): app = QApplication(argv) gl_format = QtOpenGL.QGLFormat() gl_format.setSampleBuffers(True) gl_widget = QtOpenGL.QGLWidget(gl_format) view = GraphicsView() view.setViewport(gl_widget) view.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) scene = OpenGLScene(gl_widget.context()) overlay_widget = OverlayWidget() scene.addWidget(overlay_widget) overlay_widget.change_signal.connect(scene.sliders_changed) scene.rotation_changed.connect(overlay_widget.rotation_changed) overlay_widget.move(QtCore.QPoint(0,0)) overlay_widget.setAttribute(QtCore.Qt.WA_TranslucentBackground) view.setScene(scene) print view.children() view.show() view.resize(1024,768) scene.model.setXRotation(45*16) sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) editor = pyqode.core.QGenericCodeEdit() editor.show() # show the api pyqode is currently using editor.setPlainText("pyQode using %s" % os.environ["QT_API"]) app.exec_()
def main(): app = QApplication(sys.argv) prog = LightChaser() prog.setWindowTitle("Light Chaser") prog.show() return app.exec_()
class QmlGui(Gui): USES = ['geonames', 'qmllocationprovider'] def __init__(self, core, dataroot, parent=None): self.app = QApplication(sys.argv) self.core = core self.view = QDeclarativeView() self.view.statusChanged.connect(self._status_changed) glw = QGLWidget() self.view.setViewport(glw) self.controller = Controller(self.view, self.core) self.settings = SettingsWrapper(self.core) rc = self.view.rootContext() rc.setContextProperty('controller', self.controller) rc.setContextProperty('settings', self.settings) rc.setContextProperty('gps', GPSDataWrapper(self.core)) self.view.setSource(os.path.join('qml','main.qml')) def get_gps(self, callback): self.controller.callback_gps = callback def show(self): self.view.showFullScreen() self.app.exec_() self.core.on_destroy() def _status_changed(self, error): logger.error(self.view.errors())
def link_click_handler(self, url): if url.path() == u'blank': if url.hasFragment(): if url.fragment() == u'quit': QApplication.instance().quit() else: QDesktopServices.openUrl(url)
def main(argv=None): if argv is None: argv = sys.argv app = QApplication(argv) engine = QScriptEngine() if HAS_DEBUGGER: debugger = QScriptEngineDebugger() debugger.attachTo(engine) debugWindow = debugger.standardWindow() debugWindow.resize(1024, 640) scriptFileName = './calculator.js' scriptFile = QFile(scriptFileName) scriptFile.open(QIODevice.ReadOnly) engine.evaluate(unicode(scriptFile.readAll()), scriptFileName) scriptFile.close() loader = QUiLoader() ui = loader.load(':/calculator.ui') ctor = engine.evaluate('Calculator') scriptUi = engine.newQObject(ui, QScriptEngine.ScriptOwnership) calc = ctor.construct([scriptUi]) if HAS_DEBUGGER: display = ui.findChild(QLineEdit, 'display') display.connect(display, SIGNAL('returnPressed()'), debugWindow, SLOT('show()')) ui.show() return app.exec_()
def read_response(self, until="ok", ignoreInitialize = False): """ read lines from the grbl until the expected matching line appears (usually "ok"), or just the first line if until is None. """ result = [] while True: while not self.serial.inWaiting > 0: QApplication.processEvents() line = self.serial.readline().strip() #print "Received line:", line if pycnc_config.SERIAL_DEBUG: if line == "": self.serial.write("\n") if line.startswith("error:") or line.startswith("ALARM:"): self.analyzer.undo() self.grbl_error.emit(line) break if not ignoreInitialize and line.startswith("Grbl"): # a spontaneous reset is detected? # restore work coordinates self.do_command("G10 P0 L20 X%.4f Y%.4f Z%.4f" % (self.analyzer.x, self.analyzer.y, self.analyzer.z)) break result.append(line) if line == until or until == None: break time.sleep(0.1) return '\n'.join(result)
def main(argv): app = QApplication(argv) window = MainWindow() window.show() window.raise_() window.clearFocus() app.exec_()
def main(): app = QApplication(sys.argv) # connect to the current user's session bus bus = dbus.SessionBus(mainloop=DBusGMainLoop()) try: # try to connect to our service. If this fails with a dbus # exception, the application is already running. mainwindow = bus.get_object('lunar.Qt4DBusTest', '/lunar/Qt4DBusTest/MainWindow') except dbus.DBusException: # the application is not running, so the service is registered and # the window created name = dbus.service.BusName('lunar.Qt4DBusTest', bus) mainwindow = DBusTrayMainWindow() # register the service object for the main window mainwindowobject = DBusTrayMainWindowObject(mainwindow, bus) # show the window and get the message loop running mainwindow.show() app.exec_() else: # the try clause completed, the application must therefore be # running. Now the mainwindow is shown and activated. mainwindow.show() mainwindow.activateWindow()
def goWithTheFlow(): """ goWithTheFlow handles all of the necessary aspects of starting the FluiDev application. This consists of creating/initializing the db, creating a QApplication, creating the main FluiDevWindow and then executing the application. app - QApplication necessary in every PySide application fluiDevWindow - QMainWindow object that represent the first window the user will see when they run the application """ fd_websites = list() db_file = 'FluiDev.db' db_schema_file = 'FluiDevSchema.sql' db_is_new = not os.path.exists(db_file) with sqlite3.connect(db_file) as conn: if db_is_new: with open(db_schema_file, 'rt') as schema_file: schema = schema_file.read() conn.executescript(schema) fd_websites = FluiDevWebsite.read( conn, 'website_name, website_path, date_created, date_edited', 'FluiDevWebsite' ) conn.close() app = QApplication(sys.argv) fluiDevWindow = FluiDevWindow(fd_websites) fluiDevWindow.show() sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) CONFIG_FILE = 'config.json' CONFIG_PYSIDE_RCC = 'pyside_rcc' CONFIG_PYSIDE_UIC = 'pyside_uic' json_ = json.load(open(CONFIG_FILE, mode='r+')) pyside_rcc = json_[CONFIG_PYSIDE_RCC] if os.path.exists(json_[CONFIG_PYSIDE_RCC]) else get_pyside_rcc() pyside_uic = json_[CONFIG_PYSIDE_UIC] if os.path.exists(json_[CONFIG_PYSIDE_RCC]) else get_pyside_uic() if len(pyside_rcc) == 0 or len(pyside_uic) == 0: raise SystemExit subprocess.Popen([pyside_rcc, '../resources/MainResource.qrc', '-o', 'MainResource_rc.py']) subprocess.Popen([pyside_uic, '../ui/MainWindow.ui', '-o', 'MainWindow.py']) subprocess.Popen([pyside_uic, '../ui/SettingsWindow.ui', '-o', 'SettingsWindow.py']) subprocess.Popen([pyside_uic, '../ui/ErrorLogWindow.ui', '-o', 'ErrorLogWindow.py']) json_[CONFIG_PYSIDE_RCC] = pyside_rcc json_[CONFIG_PYSIDE_UIC] = pyside_uic with open(CONFIG_FILE, 'w') as json_file: json.dump(json_, json_file, sort_keys=True, indent=4, separators=(',', ':')) app.quit()
def main(): app = QApplication(sys.argv) # this is used for the window title app.setApplicationName('PoC audio player') mainwindow = PlaybackWindow() mainwindow.show() app.exec_()
def main(): if len(sys.argv) < 3: sys.exit('please specifiy website url and image path') website, image_path = sys.argv[1], sys.argv[2] app = QApplication(sys.argv) renderer = ImageRenderer(website, image_path) app.exec_()
def main(): import sys app = QApplication(sys.argv) window = CustomCircuitCreator() window.show() sys.exit(app.exec_())
def mousePressEvent(self, QMouseEvent): self.hide() xd = QApplication.desktop().screenGeometry().x() - QApplication.desktop().availableGeometry().x() yd = QApplication.desktop().screenGeometry().y() - QApplication.desktop().availableGeometry().y() self.pos = numpy.array([QMouseEvent.pos().x()-xd, QMouseEvent.pos().y()-yd]) self.emit(SIGNAL("mouse_press()"))
def typeChanged(self,typeName): if typeName == "None": self.MeshObject.ViewObject.NodeColor = {} self.MeshObject.ViewObject.ElementColor = {} return QApplication.setOverrideCursor(Qt.WaitCursor) if typeName[:2] == "Ua" and self.DisplacementObject: (min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject) if typeName[:2] == "U1" and self.DisplacementObject: (min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject,1) if typeName[:2] == "U2" and self.DisplacementObject: (min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject,2) if typeName[:2] == "U3" and self.DisplacementObject: (min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject,3) if typeName[:2] == "Sa" and self.StressObject: (min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.StressObject) self.form.lineEdit_Max.setText(str(max)) self.form.lineEdit_Min.setText(str(min)) self.form.lineEdit_Avg.setText(str(avg)) print typeName QtGui.qApp.restoreOverrideCursor()
def run(local=False, host="localhost", port=8090): if local: from SeaGoatVision.server.core.manager import Manager # Directly connected to the vision server c = Manager() else: from SeaGoatVision.client.controller.controllerProtobuf import ControllerProtobuf # Protobuf c = ControllerProtobuf(host, port) if not c.is_connected(): logger.critical("Vision server is not accessible. Exit now.") return app = QApplication(sys.argv) win = main.WinMain(c, host=host, islocal=local) win.show() try: rint = app.exec_() except Exception as e: logger.critical("Exit error : %s" % e) # close the server win.quit() c.close() return rint
def run_emulator( sysargv, use_LNdigital, init_board, emulated_LN): app = QApplication(sysargv) emu_window = LNdigitalEmulatorWindow() if use_LNdigital: emu_window.LNdigital = LNdigitalIO.LNdigitals( hardware_addr=emulated_LN.hardware_addr, bus=emulated_LN.bus, chip_select=emulated_LN.chip_select, init_board=init_board) emu_window.current_LN = emulated_LN.hardware_addr start_q_watcher(app, emu_window, emulated_LN.proc_comms_q_to_em, emulated_LN.proc_comms_q_from_em) # only watch inputs if there is actually a LN digital if emu_window.LNdigital is not None: start_input_watcher(app, emu_window) emu_window.show() app.exec_()
def __init__(self, theScene, parent): """ Default class constructor. :param `theScene`: TOWRITE :type `theScene`: `QGraphicsScene`_ :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ """ super(EmbDetailsDialog, self).__init__(parent) self.setMinimumSize(750, 550) self.getInfo() mainWidget = self.createMainWidget() buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) vboxLayoutMain = QVBoxLayout(self) vboxLayoutMain.addWidget(mainWidget) vboxLayoutMain.addWidget(buttonBox) self.setLayout(vboxLayoutMain) self.setWindowTitle(self.tr("Embroidery Design Details")) QApplication.setOverrideCursor(Qt.ArrowCursor)
def run_gmsh(self): QApplication.setOverrideCursor(Qt.WaitCursor) self.Start = time.time() self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) self.console_message_gmsh = '' self.gmsh_runs = True self.console_log("We gone start ...") self.get_active_analysis() self.set_mesh_params() import FemGmshTools gmsh_mesh = FemGmshTools.FemGmshTools(self.obj, self.analysis) self.console_log("Start GMSH ...") error = '' try: error = gmsh_mesh.create_mesh() except: import sys print("Unexpected error when creating mesh: ", sys.exc_info()[0]) if error: print(error) self.console_log('GMSH had warnings ...') self.console_log(error, '#FF0000') else: self.console_log('Clean run of GMSH') self.console_log("GMSH done!") self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start)) self.Timer.stop() self.update() QApplication.restoreOverrideCursor()
def browse(url, name='', icon=''): from PySide.QtGui import QApplication, QIcon from PySide.QtCore import QUrl from PySide.QtWebKit import QWebView for try_ in range(10): try: assert urllib2.urlopen(url).code == 200 except (AssertionError, urllib2.URLError): time.sleep(0.25) else: print "Started Qt Web View after %i ticks." % try_ break else: sys.exit("Error initializing Qt Web View.") qtapp = QApplication(name) web = QWebView() web.load(QUrl(url)) if icon: print "Setting Icon to", icon web.setWindowIcon(QIcon(icon)) else: print "WARNING: No icon found in settings.py" web.setWindowTitle(name) web.show() qtapp.exec_()
def main(): app = QApplication(sys.argv) mainwindow = MainWindow() mainwindow.show() app.exec_()
self.files2.addItems(L1) self.files2.setCurrentIndex(-1) self.files1.currentIndexChanged.connect( lambda: self.returnString(self.files1)) self.files2.currentIndexChanged.connect( lambda: self.returnString(self.files2)) self.setUpUI() def setUpUI(self): layout = QVBoxLayout() form = QFormLayout() form.addRow(QLabel("Satellite Data File"), self.files1) form.addRow(QLabel("Work Station Position DataFile"), self.files2) layout.addLayout(form) self.setLayout(layout) def returnString(self, files): if (files == self.files1): self.fn1 = str(self.files1.currentText()) else: self.fn2 = str(self.files2.currentText()) app = QApplication(sys.argv) sf = SearchFile() sf.show() (app.exec_()) readFromFile(sf.fn1, sf.fn2)
self._previewing = True self.buttonPreview.setText('click on text to hide preview') # enable scrollbar ? self.textPreview.setText(self.printDict()) self.textPreview.setVisible(True) def printDict(self): dictText = "{\n" for k, v in self.dict().items(): dictText += " {} {};\n".format(str(k), str(v)) dictText += "}" return dictText if __name__ == '__main__': app = QApplication(sys.argv) #ex = App() mw = QMainWindow() mw.setWindowTitle('PyQt FoamBoundaryWidget test') variables = { 'p': { "type": "codedFixedValue", "value": "uniform 0", "redirectType": "rampedFixedValue", # Name of generated boundary condition "code": """ #{ const scalar t = this->db().time().value();
#TODO don't have this as a global mainWindow = None if __name__ == '__main__': parser = argparse.ArgumentParser(description='BraidsTag server.') args = parser.parse_args() gameState = ServerGameState() main = ListeningThread(gameState) main.start() # Create Qt application app = QApplication(sys.argv) mainWindow = MainWindow(gameState) mainWindow.show() # Enter Qt main loop retval = app.exec_() for i in gameState.players.values(): print(i) main.stop() gameState.terminate() #print >> sys.stderr, "\n*** STACKTRACE - START ***\n" #code = [] #for threadId, stack in sys._current_frames().items():
def __init__(self, display=True): self.app = QApplication([]) QWebView.__init__(self) if display: self.show() # show the browser
def CreateMenus(self): """ Function to create actual menu bar """ self.fileMenu = self.menuBar().addMenu("&File") self.editMenu = self.menuBar().addMenu("&Edit") self.viewMenu = self.menuBar().addMenu("&View") self.helpMenu = self.menuBar().addMenu("&Help") def CreateToolBar(self): """ Function to create tool bar """ self.mainToolBar = self.addToolBar('Main') if __name__ == '__main__': # Exception Handeling try: myApp = QApplication(sys.argv) mainWindow = MainWindow() mainWindow.SetupComponents() mainWindow.show() myApp.exec_() sys.exit(0) except NameError: print("Name Error", sys.exc_info()[1]) except SystemExit: print("Closing Window...") except Exception: print(sys.exc_info()[1])
def main(): logging.basicConfig(filename='zero.log', level=logging.DEBUG) app = QApplication(sys.argv) mw = ZMainWindow() #mw.show() sys.exit(app.exec_())
class UI(gobject.GObject): __gsignals__ = { 'command': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, )) } def __init__(self, args, continuous): self.continuous = continuous gobject.GObject.__init__(self) #start by making our app self.app = QApplication(args) #make a window self.window = QMainWindow() #give the window a name self.window.setWindowTitle("BlatherQt") self.window.setMaximumSize(400, 200) center = QWidget() self.window.setCentralWidget(center) layout = QVBoxLayout() center.setLayout(layout) #make a listen/stop button self.lsbutton = QPushButton("Listen") layout.addWidget(self.lsbutton) #make a continuous button self.ccheckbox = QCheckBox("Continuous Listen") layout.addWidget(self.ccheckbox) #connect the buttons self.lsbutton.clicked.connect(self.lsbutton_clicked) self.ccheckbox.clicked.connect(self.ccheckbox_clicked) #add a label to the UI to display the last command self.label = QLabel() layout.addWidget(self.label) #add the actions for quiting quit_action = QAction(self.window) quit_action.setShortcut('Ctrl+Q') quit_action.triggered.connect(self.accel_quit) self.window.addAction(quit_action) def accel_quit(self): #emit the quit self.emit("command", "quit") def ccheckbox_clicked(self): checked = self.ccheckbox.isChecked() if checked: #disable lsbutton self.lsbutton.setEnabled(False) self.lsbutton_stopped() self.emit('command', "continuous_listen") else: self.lsbutton.setEnabled(True) self.emit('command', "continuous_stop") def lsbutton_stopped(self): self.lsbutton.setText("Listen") def lsbutton_clicked(self): val = self.lsbutton.text() if val == "Listen": self.emit("command", "listen") self.lsbutton.setText("Stop") #clear the label self.label.setText("") else: self.lsbutton_stopped() self.emit("command", "stop") def run(self): self.window.show() if self.continuous: self.ccheckbox.setCheckState(Qt.Checked) self.ccheckbox_clicked() self.app.exec_() self.emit("command", "quit") def finished(self, text): print text #if the continuous isn't pressed if not self.ccheckbox.isChecked(): self.lsbutton_stopped() self.label.setText(text) def set_icon(self, icon): self.window.setWindowIcon(QIcon(icon))
__author__ = 'waterstrider.vin' from sys import argv from PySide.QtGui import QApplication from uSourceImage.uSourceImageWidget import USourceImageWidget if __name__ == "__main__": app = QApplication(argv) uSourceImageWidget = USourceImageWidget() uSourceImageWidget.show() app.exec_()
deleteItem = form.exec_() if deleteItem: item = self.listWidget.takeItem(row) del item self.updateUi() def help(self): self.state.help("xix_ref_dlg_groups.html") if __name__ == "__main__": import collections import Qrc # noqa import HelpForm Entry = collections.namedtuple("Entry", "eid term peid") app = QApplication([]) app.setOrganizationName("Qtrac Ltd.") app.setOrganizationDomain("qtrac.eu") app.setApplicationName("XindeX-Test") app.setApplicationVersion("1.0.0") entries = {100: "term #1", 200: "term #2", 300: "term #3"} groups = { 3: "scene selection", 5: "code generation", 4: "special method", 6: "ttk widget" } class FakeModel: def safeToLinkGroup(self, gid): return not self.isLinkedGroup(gid)
def main(): app = QApplication(argv) puzzle = FifteenPuzzle(4, 4) gui = FifteenGui(puzzle) app.exec_()
def main(): app = QApplication(argv) header = Header() header.show() exit(app.exec_())
def setup(self): """initializes the uio of the erp client""" self.progress.setFixedWidth(1000) self.progress.setCancelButton(None) # self.progress.setWindowModality(Qt.WindowModal) self.progress.setValue(1) self.mainwindow.setObjectName("MainWindow") self.mainwindow.resize(832, 668) self.mainwindow.setStyleSheet( "QToolBar{\n" "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,\n" "stop:0 rgba(0,0,0),stop:1 rgb(162, 162, 162, 162));\n" "border: 0px;\n" "}\n" "QToolBar > QWidget{\n" "color:white;\n" "}\n" "QToolBar > QWidget:hover {\n" "background:transparent;\n" " }\n" "QToolBar > QWidget:checked {\n" "background:transparent;\n" " }\n" "#MainWindow{\n" "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,\n" "stop:0 rgba(0,0,0),stop:1 rgb(162, 162, 162, 162));\n" "border: 0px;\n" "}\n" "") self.centralWidget = QWidget(self.mainwindow) self.centralWidget.setObjectName("centralWidget") self.gridLayout_2 = QGridLayout(self.centralWidget) self.gridLayout_2.setObjectName("gridLayout_2") self.stackedWidget = QStackedWidget(self.centralWidget) self.stackedWidget.setStyleSheet("") self.stackedWidget.setObjectName("stackedWidget") self.shortcut = NewShortcut() scroll = QScrollArea() scroll.setWidget(self.shortcut.shortcut_setting) self.stackedWidget.addWidget(self.shortcut.shortcut_setting) self.home_page = QWidget() self.home_page.setObjectName("home_page") self.gridLayout = QGridLayout(self.home_page) self.gridLayout.setObjectName("gridLayout") self.billing_frame_2 = QFrame(self.home_page) self.billing_frame_2.setStyleSheet( "background-image:url(:/images/billing_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#6CBED2;") self.billing_frame_2.setFrameShape(QFrame.StyledPanel) self.billing_frame_2.setFrameShadow(QFrame.Raised) self.billing_frame_2.setObjectName("billing_frame_2") self.verticalLayout_4 = QVBoxLayout(self.billing_frame_2) self.verticalLayout_4.setObjectName("verticalLayout_4") spacerItem = QSpacerItem(20, 217, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem) self.label_10 = QLabel(self.billing_frame_2) self.label_10.setStyleSheet("background:transparent;") self.label_10.setObjectName("label_10") self.verticalLayout_4.addWidget(self.label_10) self.gridLayout.addWidget(self.billing_frame_2, 0, 1, 1, 1) self.employee_frame_3 = QFrame(self.home_page) self.employee_frame_3.setStyleSheet( "background-image:url(:/images/employee_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#0099CC;") self.employee_frame_3.setFrameShape(QFrame.StyledPanel) self.employee_frame_3.setFrameShadow(QFrame.Raised) self.employee_frame_3.setObjectName("employee_frame_3") self.verticalLayout_5 = QVBoxLayout(self.employee_frame_3) self.verticalLayout_5.setObjectName("verticalLayout_5") spacerItem1 = QSpacerItem(20, 217, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_5.addItem(spacerItem1) self.label_11 = QLabel(self.employee_frame_3) self.label_11.setStyleSheet("background:transparent;") self.label_11.setObjectName("label_11") self.verticalLayout_5.addWidget(self.label_11) self.gridLayout.addWidget(self.employee_frame_3, 0, 2, 1, 1) self.menu_frame_4 = QFrame(self.home_page) self.menu_frame_4.setStyleSheet( "background-image:url(:/images/menu_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#297ACC;") self.menu_frame_4.setFrameShape(QFrame.StyledPanel) self.menu_frame_4.setFrameShadow(QFrame.Raised) self.menu_frame_4.setObjectName("menu_frame_4") self.verticalLayout_3 = QVBoxLayout(self.menu_frame_4) self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem2 = QSpacerItem(20, 216, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem2) self.label_12 = QLabel(self.menu_frame_4) self.label_12.setStyleSheet("background:transparent;") self.label_12.setObjectName("label_12") self.verticalLayout_3.addWidget(self.label_12) self.gridLayout.addWidget(self.menu_frame_4, 1, 0, 1, 1) self.report_frame_5 = QFrame(self.home_page) self.report_frame_5.setStyleSheet( "background-image:url(:/images/report_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#006BB2;") self.report_frame_5.setFrameShape(QFrame.StyledPanel) self.report_frame_5.setFrameShadow(QFrame.Raised) self.report_frame_5.setObjectName("report_frame_5") self.verticalLayout_6 = QVBoxLayout(self.report_frame_5) self.verticalLayout_6.setObjectName("verticalLayout_6") spacerItem3 = QSpacerItem(20, 216, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_6.addItem(spacerItem3) self.label_13 = QLabel(self.report_frame_5) self.label_13.setStyleSheet("background:transparent;") self.label_13.setObjectName("label_13") self.verticalLayout_6.addWidget(self.label_13) self.gridLayout.addWidget(self.report_frame_5, 1, 1, 1, 1) self.waste_frame_6 = QFrame(self.home_page) self.waste_frame_6.setStyleSheet( "background-image:url(:/images/waste_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#003D7A;") self.waste_frame_6.setFrameShape(QFrame.StyledPanel) self.waste_frame_6.setFrameShadow(QFrame.Raised) self.waste_frame_6.setObjectName("waste_frame_6") self.verticalLayout_7 = QVBoxLayout(self.waste_frame_6) self.verticalLayout_7.setObjectName("verticalLayout_7") spacerItem4 = QSpacerItem(20, 216, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_7.addItem(spacerItem4) self.label_14 = QLabel(self.waste_frame_6) self.label_14.setStyleSheet("background:transparent;") self.label_14.setObjectName("label_14") self.verticalLayout_7.addWidget(self.label_14) self.gridLayout.addWidget(self.waste_frame_6, 1, 2, 1, 1) self.inventory_frame_1 = QFrame(self.home_page) self.inventory_frame_1.setStyleSheet( "background-image:url(:/images/inventory_frame.png);\n" "background-repeat: no-repeat;\n" "background-position: center;\n" "background-color:#ADEBFF;") self.inventory_frame_1.setFrameShape(QFrame.StyledPanel) self.inventory_frame_1.setFrameShadow(QFrame.Raised) self.inventory_frame_1.setObjectName("inventory_frame_1") self.verticalLayout_2 = QVBoxLayout(self.inventory_frame_1) self.verticalLayout_2.setObjectName("verticalLayout_2") spacerItem5 = QSpacerItem(20, 217, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem5) self.label_9 = QLabel(self.inventory_frame_1) self.label_9.setStyleSheet("background:transparent;") self.label_9.setObjectName("label_9") self.verticalLayout_2.addWidget(self.label_9) self.gridLayout.addWidget(self.inventory_frame_1, 0, 0, 1, 1) self.stackedWidget.addWidget(self.home_page) self.detail_page = QWidget() self.detail_page.setObjectName("detail_page") self.horizontalLayout_2 = QHBoxLayout(self.detail_page) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.main_tabWidget = QTabWidget(self.detail_page) self.main_tabWidget.setAutoFillBackground(False) self.main_tabWidget.setStyleSheet("") self.main_tabWidget.setTabPosition(QTabWidget.West) self.main_tabWidget.setIconSize(QSize(60, 60)) self.main_tabWidget.setElideMode(Qt.ElideNone) self.main_tabWidget.setObjectName("main_tabWidget") ##initializes the tabs self.add_tabs() self.main_tabWidget.setFocusPolicy(Qt.StrongFocus) self.main_tabWidget.focusInEvent = self.change_focus self.main_tabWidget.currentChanged.connect(self.change_focus) self.stackedWidget.currentChanged.connect(self.change_focus) ###### self.horizontalLayout_2.addWidget(self.main_tabWidget) self.stackedWidget.addWidget(self.detail_page) if ('Admin', True) in self.access: self.stackedWidget.addWidget(Admin(self.mainwindow)) notification = NotificationTab() tab = notification.notificationTab_tab_4 tab.custom_class_object = notification # class_object is used to access the api through the self.stackedWidget.addWidget(tab) self.gridLayout_2.addWidget(self.stackedWidget, 0, 0, 1, 1) self.mainwindow.setCentralWidget(self.centralWidget) self.menuBar = QMenuBar(self.mainwindow) self.menuBar.setGeometry(QRect(0, 0, 832, 29)) self.menuBar.setObjectName("menuBar") self.mainwindow.setMenuBar(self.menuBar) self.mainToolBar = QToolBar(self.mainwindow) self.mainToolBar.setLayoutDirection(Qt.RightToLeft) self.mainToolBar.setStyleSheet("") self.mainToolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.mainToolBar.setObjectName("mainToolBar") self.mainwindow.addToolBar(Qt.TopToolBarArea, self.mainToolBar) self.statusBar = QStatusBar(self.mainwindow) self.statusBar.setObjectName("statusBar") self.mainwindow.setStatusBar(self.statusBar) self.toolBar = QToolBar(self.mainwindow) self.toolBar.setLayoutDirection(Qt.RightToLeft) self.toolBar.setStyleSheet("") self.toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.toolBar.setObjectName("toolBar") self.mainwindow.addToolBar(Qt.TopToolBarArea, self.toolBar) self.actionNotification = QAction(self.mainwindow) self.actionNotification.setCheckable(True) self.actionNotification.setChecked(False) self.actionNotification.setEnabled(True) icon6 = QIcon() icon6.addPixmap(QPixmap(":/images/notification.png"), QIcon.Normal, QIcon.Off) self.actionNotification.setIcon(icon6) self.actionNotification.setAutoRepeat(True) self.actionNotification.setVisible(True) self.actionNotification.setIconVisibleInMenu(False) self.actionNotification.setObjectName("actionNotification") self.actionNotification self.actionAdmin = QAction(self.mainwindow) # self.actionAdmin.setCheckable(True) icon7 = QIcon() icon7.addPixmap(QPixmap(":/images/admin.png"), QIcon.Normal, QIcon.Off) self.actionAdmin.setIcon(icon7) self.actionAdmin.setObjectName("actionAdmin") self.actionRefresh = QAction(self.mainwindow) icon8 = QIcon() icon8.addPixmap(QPixmap(":/images/refresh.png"), QIcon.Normal, QIcon.Off) self.actionRefresh.setIcon(icon8) self.actionRefresh.setObjectName("actionRefresh") self.actionHome = QAction(self.mainwindow) # self.actionHome.setCheckable(True) icon9 = QIcon() icon9.addPixmap(QPixmap(":/images/home.png"), QIcon.Normal, QIcon.Off) self.actionHome.setIcon(icon9) self.actionHome.setObjectName("actionHome") self.actionSettings = QAction(self.mainwindow) icon10 = QIcon() icon10.addPixmap(QPixmap(":/images/settings.png"), QIcon.Normal, QIcon.Off) self.actionSettings.setIcon(icon10) self.actionSettings.setObjectName("actionRefresh") self.toolBar.addAction(self.actionNotification) self.toolBar.addSeparator() self.toolBar.addAction(self.actionAdmin) if ('Admin', True) in self.access: self.toolBar.addSeparator() else: self.actionAdmin.setVisible(False) self.toolBar.addAction(self.actionHome) self.toolBar.addSeparator() self.toolBar.addAction(self.actionRefresh) self.toolBar.addSeparator() self.toolBar.addAction(self.actionSettings) ##retranslates self.mainwindow.setWindowTitle( QApplication.translate("MainWindow", settings.company, None, QApplication.UnicodeUTF8)) self.label_10.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">BILLING</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_11.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">EMPLOYEE</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_12.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">MENU</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_13.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">REPORT</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_14.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">WASTE</p></body></html>", None, QApplication.UnicodeUTF8)) self.label_9.setText( QApplication.translate( "MainWindow", "<html><head/><body><p align=\"center\">INVENTORY</p></body></html>", None, QApplication.UnicodeUTF8)) self.inventory_frame_1.setToolTip( QApplication.translate("MainWindow", "Go to the Inventory Tab", None, QApplication.UnicodeUTF8)) self.billing_frame_2.setToolTip( QApplication.translate("MainWindow", "Go to the Billing Tab", None, QApplication.UnicodeUTF8)) self.employee_frame_3.setToolTip( QApplication.translate("MainWindow", "Go to the Employee Tab", None, QApplication.UnicodeUTF8)) self.menu_frame_4.setToolTip( QApplication.translate("MainWindow", "Go to the Menu Tab", None, QApplication.UnicodeUTF8)) self.report_frame_5.setToolTip( QApplication.translate("MainWindow", "Go to the Report Tab", None, QApplication.UnicodeUTF8)) self.waste_frame_6.setToolTip( QApplication.translate("MainWindow", "Go to the Waste Tab", None, QApplication.UnicodeUTF8)) self.toolBar.setWindowTitle( QApplication.translate("MainWindow", "toolBar", None, QApplication.UnicodeUTF8)) self.actionNotification.setText("&&Notification") # QApplication.translate("MainWindow", "&Notification", None, QApplication.UnicodeUTF8)) self.actionNotification.setToolTip( QApplication.translate("MainWindow", "Click to see new notifications", None, QApplication.UnicodeUTF8)) # self.actionNotification.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+N", None, QApplication.UnicodeUTF8)) self.actionAdmin.setText('&&Admin') # QApplication.translate("MainWindow", "Admin", None, QApplication.UnicodeUTF8)) self.actionAdmin.setToolTip( QApplication.translate("MainWindow", "Click to go to admin interface", None, QApplication.UnicodeUTF8)) # self.actionAdmin.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+A", None, QApplication.UnicodeUTF8)) self.actionRefresh.setText("&&Refresh") # QApplication.translate("MainWindow", "Refresh", None, QApplication.UnicodeUTF8)) self.actionRefresh.setToolTip( QApplication.translate("MainWindow", "refreshes the data from the server", None, QApplication.UnicodeUTF8)) # self.actionRefresh.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+R", None, QApplication.UnicodeUTF8)) self.actionHome.setText('&&Home') # QApplication.translate("MainWindow", "Home", None, QApplication.UnicodeUTF8)) self.actionHome.setToolTip( QApplication.translate("MainWindow", "Go back to the home screen", None, QApplication.UnicodeUTF8)) self.actionSettings.setText('&&Settings') # QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.actionSettings.setToolTip( QApplication.translate("MainWindow", "Go to the settings panel", None, QApplication.UnicodeUTF8)) # self.actionHome.setShortcut( # QApplication.translate("MainWindow", "Ctrl+Shift+H", None, QApplication.UnicodeUTF8)) self.stackedWidget.setCurrentIndex(1) self.main_tabWidget.setCurrentIndex(0) self.ob = self.main_tabWidget.tabBar() # self.add_tool_tip(self.ob) todo avoided due to segmentation fault error, left for future fixes self.tb = EventHandlerForTabBar() self.ob.installEventFilter(self.tb) QMetaObject.connectSlotsByName(self.mainwindow)
def stop(self): if self.clipThread is not None: self.stopClipboardThread() QApplication.exit() sys.exit()
def __init__(self, parent=None): """ Default class constructor. :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ """ super(AboutDialog, self).__init__(parent) p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p) if parent: self.gImgDir = parent.gImgDir self.gIconDir = parent.gIconDir elif __name__ == '__main__': self.gImgDir = gAppDir + os.sep + 'images' self.gIconDir = gAppDir + os.sep + 'icons' + os.sep + 'default' # The tiled theme background texture. self.bgLogo = QPixmap(self.gImgDir + os.sep + 'texture-spirals.png') self.bgBrush = QBrush(self.bgLogo) self.setWhatsThis( self.tr("""\ The background is a tiled image of an actual design that was stitched out during the pre-alpha stage. It was created by Nina Paley and Theodore Gray using Mathematica in conjunction with our software. They have graciously allowed us to use it for the project in whichever way we wish. We thought it looked so good, that it has become the new theme for Embroidermodder 2. To check out some of the more interesting embroidery projects they are working on, visit http://blog.ninapaley.com/""")) self.imgLbl = EmbroidermodderLogo(self) aboutLbl = QTextBrowser(self) aboutLbl.setReadOnly(True) aboutLbl.setOpenExternalLinks(True) aboutLbl.setText('<b>%s</b>' % '<br>'.join(ABOUT.split('\n'))) aboutLbl.setWhatsThis( self. tr('This is the AWESOME people that brought Embroidermodder 2 to life.' )) # We want very slight opacity of the white background # so the seamless texture shows slightly through. opacityStyleSheet = """\ QTextEdit:read-only { color: rgb(50, 50, 50); font-size: 12px; font-weight: bold; background-color: rgba(255, 255, 255, 240); border: 1px solid rgba(0, 0, 0, 255); } """ aboutLbl.setStyleSheet(opacityStyleSheet) op = QGraphicsOpacityEffect(aboutLbl) op.setOpacity(0.95) aboutLbl.setGraphicsEffect(op) self.notebook = QTabWidget(self) self.notebook.setMinimumWidth(500) self.notebook.addTab(aboutLbl, self.tr('About')) self.notebook.setTabIcon(0, QIcon(self.gIconDir + os.sep + 'app.png')) self.notebook.setTabIcon( 1, QIcon(self.gImgDir + os.sep + 'kickstarter-logo-k-color.png')) notebookStyleSheet = """\ QTabWidget::pane { /* The tab widget frame */ border-top: 1px solid #000000; position: absolute; top: -0.5em; } QTabWidget::tab-bar { alignment: center; } /* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ QTabBar::tab { margin-top: 2px; /* make non-selected tabs look smaller */ font-size: 14px; font-weight: bold; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); border: 1px solid #000000; /* border-bottom-color: #C2C7CB; */ /* same as the pane color */ border-top-left-radius: 4px; border-top-right-radius: 4px; min-width: 40ex; min-height: 5ex; padding: 3px; } QTabBar::tab:selected { margin-top: 0px; font-size: 16px; font-weight: bold; background: qlineargradient(x1: 0, y1: 0, x2: 2, y2: 2, stop: 0 #0C6AB0, stop: 0.15 #55C4E6, stop: 0.15 #55C4E6, stop: 0.5 #FFFFFF, stop: 0.5 #FFFFFF, stop: 0.85 #55C4E6, stop: 0.85 #55C4E6, stop: 1.0 #0C6AB0); border: 1px solid #000000; } QTabBar::tab:!selected:hover { margin-top: 2px; /* make non-selected tabs look smaller */ font-size: 14px; font-weight: bold; background: qlineargradient(x1: 0, y1: 0, x2: 2, y2: 2, stop: 0 #888888, stop: 0.15 #BBBBBB, stop: 0.15 #BBBBBB, stop: 0.5 #FFFFFF, stop: 0.5 #FFFFFF, stop: 0.85 #BBBBBB, stop: 0.85 #BBBBBB, stop: 1.0 #888888); border: 1px solid #000000; } QTabBar::tab:selected { border-color: #000000; border-bottom-color: #000000; /* same as pane color */ } """ self.notebook.setStyleSheet(notebookStyleSheet) self.notebook.currentChanged.connect(self.CurrentTabChanged) buttonbox = QDialogButtonBox(Qt.Horizontal, self) button = QPushButton(self) button.setText(self.tr("Oh, Yeah!")) button.setWhatsThis( self.tr('This is the Oh, Yeah! button!') + '\n' + self.tr('Oh, Yeah!')) buttonbox.addButton(button, QDialogButtonBox.AcceptRole) buttonbox.setCenterButtons(True) buttonbox.accepted.connect(self.accept) hbLayout1 = QHBoxLayout() hbLayout2 = QHBoxLayout() vbLayout = QVBoxLayout() hbLayout1.addStretch() hbLayout1.addWidget(self.imgLbl) hbLayout1.addStretch() hbLayout2.addStretch() hbLayout2.addWidget(self.notebook) hbLayout2.addStretch() vbLayout.addLayout(hbLayout1) vbLayout.addLayout(hbLayout2) vbLayout.addWidget(buttonbox) self.setLayout(vbLayout) self.setWindowTitle(self.tr('About Embroidermodder Version 2.0')) QApplication.restoreOverrideCursor( ) # TODO/???/PORT# don't mess with the window resize cursors.
self.setWindowTitle("Add a Contact") buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) # These properties make using this dialog a little cleaner. It's much # nicer to type "addDialog.address" to retrieve the address as compared # to "addDialog.addressText.toPlainText()" @property def name(self): return self.nameText.text() @property def address(self): return self.addressText.toPlainText() if __name__ == "__main__": import sys from PySide.QtGui import QApplication app = QApplication(sys.argv) dialog = AddDialog() if (dialog.exec_()): name = dialog.name address = dialog.address print("Name:" + name) print("Address:" + address)
def setValue(self, progress): self.progressBar.setValue(progress) if self._autoReset and self.value() == self.maximum(): self.reset() if self.isModal(): QApplication.processEvents()
set_attributes = ["AA_EnableHighDpiScaling"] try: from PySide.QtGui import QWidget, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox from PySide.QtGui import QScrollArea, QTabWidget, QComboBox, QPushButton, QTextEdit from PySide.QtGui import QFileDialog, QCheckBox, QLabel, QMenuBar, QAction, QDialog from PySide.QtCore import Slot, QSize, QSettings except ImportError: try: from PySide2.QtWidgets import QWidget, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox from PySide2.QtWidgets import QScrollArea, QTabWidget, QComboBox, QPushButton, QTextEdit from PySide2.QtWidgets import QFileDialog, QCheckBox, QLabel, QMenuBar, QAction, QDialog from PySide2.QtCore import Slot, Qt, QCoreApplication, QSize, QSettings for attribute in set_attributes: QApplication.setAttribute(getattr(Qt, attribute)) except ImportError: QWidget, Slot = object, (lambda: lambda *x: None) # Quit with C-c signal.signal(signal.SIGINT, signal.SIG_DFL) def text(key, contents): desc = (contents or {}).get(input_database._desc) return desc or key def get_settings(): return QSettings('cobaya', 'gui')
def enterEvent(self, *args, **kwargs): self.highlighted = True QApplication.setOverrideCursor(Qt.PointingHandCursor) self.repaint()
@Slot(float) def changedValueFromSpinBox(self, value): if self._changed: self._changed = False return ratio = (value - self.range[0]) / (self.range[1] - self.range[0]) self._changed = True self.slider.setValue(ratio * 100.0) self.valueChanged.emit(value) if __name__ == '__main__': from PySide.QtGui import QApplication from PySide.QtGui import QVBoxLayout app = QApplication([]) sliderWidget = SliderFloatWidget() sliderWidget.setName("Test value") sliderWidget.setRange([0, 1]) sliderWidget.setValue(0.5) label = QLabel() def updateLabel(value): label.setText(str(sliderWidget.value())) sliderWidget.valueChanged.connect(updateLabel) layout = QVBoxLayout() layout.addWidget(QLabel("Test sliders"))
import sys import time import urllib from PySide.QtGui import QApplication from bin.main_window_controller import MainWindowController __version__ = "0.1.0" __author__ = "maxim" __description__ = "Minecraft mod list updater" __name___ = "MMLU" if __name__ == '__main__': # gui test q_application = QApplication(sys.argv) controller = MainWindowController() q_application.exec_() if __name__ == "__main__sdfsf": addedfiles = [] deletedfiles = [] print "versie:" + __version__ host = "http://141.134.182.253:8080/" longdir = os.getenv('APPDATA') + "/.minecraft/" dirname = "mods/" confname = "config/"
def leaveEvent(self, *args, **kwargs): self.highlighted = False QApplication.restoreOverrideCursor() self.repaint()
def copy_text(self, text): QApplication.clipboard().setText(text)
def main(): """Execute QDarkStyle example.""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--qt_from', default='qtpy', choices=['pyqt', 'pyqt5', 'pyside','pyside2', 'qtpy', 'pyqtgraph'], help="Choose which wrapper/framework is to be used to run the example.", type=str) parser.add_argument('--no_dark', action='store_true', help="Exihibts the original window (without qdarkstyle).") parser.add_argument('--test', action='store_true', help="Auto close window after 2s.") parser.add_argument('--reset', action='store_true', help="Reset GUI settings (position, size).") # parsing arguments from command line args = parser.parse_args() # set log for debug logging.basicConfig(level=logging.DEBUG) if args.qt_from == 'pyside': # using PySide wrapper from PySide.QtGui import QApplication, QMainWindow, QDockWidget from PySide.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyside() elif args.qt_from == 'pyqt': # using PyQt4 wrapper from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget from PyQt4.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt() elif args.qt_from == 'pyqt5': # using PyQt5 wrapper from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget from PyQt5.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyqt5_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqt5_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqt5_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqt5_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqt5_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqt5_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqt5_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyqt5() elif args.qt_from == 'pyside2': # using PyQt5 wrapper from PySide2.QtWidgets import QApplication, QMainWindow, QDockWidget from PySide2.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_pyside2_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyside2_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyside2_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyside2_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyside2_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyside2_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyside2_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyside2_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyside2_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_pyside2() elif args.qt_from == 'qtpy': # using QtPy API from qtpy.QtWidgets import QApplication, QMainWindow, QDockWidget from qtpy.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize # import examples UI according to wrapper from ui.mw_menus_qtpy_ui import Ui_MainWindow as ui_main from ui.dw_buttons_qtpy_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_qtpy_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_qtpy_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_qtpy_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_qtpy_ui import Ui_DockWidget as ui_widgets from ui.dw_views_qtpy_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_qtpy_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_qtpy_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment() elif args.qt_from == 'pyqtgraph': # using PyQtGraph API from pyqtgraph.Qt.QtGui import QApplication, QMainWindow, QDockWidget from pyqtgraph.Qt.QtCore import QTimer, Qt, QSettings, QByteArray, QPoint, QSize #from pyqtgraph.Qt import QtGui, QtCore # import examples UI according to wrapper from ui.mw_menus_pyqtgraph_ui import Ui_MainWindow as ui_main from ui.dw_buttons_pyqtgraph_ui import Ui_DockWidget as ui_buttons from ui.dw_displays_pyqtgraph_ui import Ui_DockWidget as ui_displays from ui.dw_inputs_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_fields from ui.dw_inputs_no_fields_pyqtgraph_ui import Ui_DockWidget as ui_inputs_no_fields from ui.dw_widgets_pyqtgraph_ui import Ui_DockWidget as ui_widgets from ui.dw_views_pyqtgraph_ui import Ui_DockWidget as ui_views from ui.dw_containers_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_tabs from ui.dw_containers_no_tabs_pyqtgraph_ui import Ui_DockWidget as ui_containers_no_tabs # getting style style = qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=True) if args.no_dark: style = '' def write_settings(window): """Get window settings and write it into a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') settings.setValue('pos', window.pos()) settings.setValue('size', window.size()) settings.setValue('state', window.saveState()) def read_settings(window, reset=False): """Read and set window settings from a file.""" settings = QSettings('QDarkStyle', 'QDarkStyle Example') if args.qt_from == 'pyside' or args.qt_from == 'pyside2': pos = settings.value('pos', window.pos()) size = settings.value('size', window.size()) state = settings.value('state', window.saveState()) else: pos = settings.value('pos', window.pos(), type='QPoint') size = settings.value('size', window.size(), type='QSize') state = settings.value('state', window.saveState(), type='QByteArray') if not reset: window.restoreState(state) window.resize(size) window.move(pos) # create the application app = QApplication(sys.argv) app.setOrganizationName('QDarkStyle') app.setApplicationName('QDarkStyle Example') # setup stylesheet app.setStyleSheet(style) # create main window window = QMainWindow() window.setObjectName('mainwindow') ui = ui_main() ui.setupUi(window) window.setWindowTitle("QDarkStyle v." + qdarkstyle.__version__) # create docks for buttons dw_buttons = QDockWidget() dw_buttons.setObjectName('buttons') ui_buttons = ui_buttons() ui_buttons.setupUi(dw_buttons) window.addDockWidget(Qt.RightDockWidgetArea, dw_buttons) # create docks for buttons dw_displays = QDockWidget() dw_displays.setObjectName('displays') ui_displays = ui_displays() ui_displays.setupUi(dw_displays) window.addDockWidget(Qt.RightDockWidgetArea, dw_displays) # create docks for inputs - no fields dw_inputs_no_fields = QDockWidget() dw_inputs_no_fields.setObjectName('inputs_no_fields') ui_inputs_no_fields = ui_inputs_no_fields() ui_inputs_no_fields.setupUi(dw_inputs_no_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_no_fields) # create docks for inputs - fields dw_inputs_fields = QDockWidget() dw_inputs_fields.setObjectName('_fields') ui_inputs_fields = ui_inputs_fields() ui_inputs_fields.setupUi(dw_inputs_fields) window.addDockWidget(Qt.RightDockWidgetArea, dw_inputs_fields) # create docks for widgets dw_widgets = QDockWidget() dw_widgets.setObjectName('widgets') ui_widgets = ui_widgets() ui_widgets.setupUi(dw_widgets) window.addDockWidget(Qt.LeftDockWidgetArea, dw_widgets) # create docks for views dw_views = QDockWidget() dw_views.setObjectName('views') ui_views = ui_views() ui_views.setupUi(dw_views) window.addDockWidget(Qt.LeftDockWidgetArea, dw_views) # create docks for containers - no tabs dw_containers_no_tabs = QDockWidget() dw_containers_no_tabs.setObjectName('containers_no_tabs') ui_containers_no_tabs = ui_containers_no_tabs() ui_containers_no_tabs.setupUi(dw_containers_no_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_no_tabs) # create docks for containters - tabs dw_containers_tabs = QDockWidget() dw_containers_tabs.setObjectName('containers') ui_containers_tabs = ui_containers_tabs() ui_containers_tabs.setupUi(dw_containers_tabs) window.addDockWidget(Qt.LeftDockWidgetArea, dw_containers_tabs) # tabify right docks window.tabifyDockWidget(dw_buttons, dw_displays) window.tabifyDockWidget(dw_displays, dw_inputs_fields) window.tabifyDockWidget(dw_inputs_fields, dw_inputs_no_fields) # tabify right docks window.tabifyDockWidget(dw_containers_no_tabs, dw_containers_tabs) window.tabifyDockWidget(dw_containers_tabs, dw_widgets) window.tabifyDockWidget(dw_widgets, dw_views) # auto quit after 2s when testing on travis-ci if args.test: QTimer.singleShot(2000, app.exit) # run qdarkstyle.information() read_settings(window, args.reset) window.showMaximized() app.exec_() write_settings(window)
def __call__(self): diag = QApplication.activeModalWidget() self.test.assertIsNotNone(diag, "Input dialog box could not be found") if (diag != None): QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()'))
def paste_seed_words(self): text = QApplication.clipboard().text() self.on_paste_seed_words_event.emit(text)
from PySide.QtGui import QApplication from ui.mainwindow import MainWindow config = Config() config.load() # Create some directories if they don't exist for dir in ['tmp', 'cache', 'cache' + os.sep + 'data']: if not os.path.exists(os.path.join(os.getcwd(), dir)): os.mkdir(os.path.join(os.getcwd(), dir)) os.chmod(os.path.join(os.getcwd(), dir), 0777) # The app if __name__ == '__main__': # Create app app = QApplication(sys.argv) app.setApplicationName('LMMS Theme Installer') # Configuration wizard if config.get('Wizard', 'firstrun') == 'True': from ui.firstrunwizard import FirstRunWizardWindow wizard = FirstRunWizardWindow() wizard.show() # Show window window = MainWindow() window.show() # Closed connection app.lastWindowClosed.connect(app.quit)
@author: Dimitri Justeau <*****@*****.**> """ import sys from PySide.QtGui import QApplication from PySide.QtCore import QTranslator from gui.mainwindow import MainWindow import constants import utils import texts if __name__ == '__main__': app = QApplication(sys.argv) translator = QTranslator() translator.load(constants.QM_PATH) app.installTranslator(translator) mainwindow = MainWindow() def excepthook(excType, excValue, tracebackobj): msg_box = utils.getCriticalMessageBox(texts.GENERAL_ERROR_TITLE, texts.GENERAL_ERROR_MSG) msg_box.exec_() app.exit() sys.excepthook = excepthook
def __init__(self): QMainWindow.__init__(self) # the user interface, consisting of a progress bar above a plain # text edit, which logs all actions. container = QWidget(self) container.setLayout(QVBoxLayout(container)) self.setCentralWidget(container) progressbar = QProgressBar(container) container.layout().addWidget(progressbar) log = QPlainTextEdit(container) container.layout().addWidget(log) # the actual worker thread counter = Counter(100, self) # an action to quit the windows exit = QAction(QIcon.fromTheme('application-exit'), 'exit', self) # add two actions to start and stop the worker to the toolbar of the # main window start_counting = QAction(QIcon.fromTheme('media-playback-start'), 'Start counting', self) stop_counting = QAction(QIcon.fromTheme('media-playback-stop'), 'Stop counting', self) # initially no counter runs, so we can disable the stop action stop_counting.setEnabled(False) # add all actions to a toolbar actions = self.addToolBar('Actions') actions.addAction(exit) actions.addSeparator() actions.addAction(start_counting) actions.addAction(stop_counting) # quit the application, if the quit action is triggered exit.triggered.connect(QApplication.instance().quit) # start and stop the counter, if the corresponding actions are # triggered. start_counting.triggered.connect(counter.start) stop_counting.triggered.connect(counter.stop) # adjust the minimum and the maximum of the progress bar, if # necessary. Not really required in this snippet, but added for the # purpose of demonstrating it counter.minimumChanged.connect(progressbar.setMinimum) counter.maximumChanged.connect(progressbar.setMaximum) # switch the enabled states of the actions according to whether the # worker is running or not counter.started.connect(partial(start_counting.setEnabled, False)) counter.started.connect(partial(stop_counting.setEnabled, True)) counter.finished.connect(partial(start_counting.setEnabled, True)) counter.finished.connect(partial(stop_counting.setEnabled, False)) # update the progess bar continuously counter.progress.connect(progressbar.setValue) # log all actions in our logging widget counter.started.connect( partial(self.statusBar().showMessage, 'Counting')) counter.finished.connect(partial(self.statusBar().showMessage, 'Done')) # log a forced stop stop_counting.triggered.connect(partial(log.appendPlainText, 'Stopped')) # log all counted values counter.progress.connect(lambda v: log.appendPlainText(str(v))) # and finally show the current state in the status bar. counter.started.connect(partial(log.appendPlainText, 'Counting')) counter.finished.connect(partial(log.appendPlainText, 'Done'))
def __call__(self): diag = QApplication.activeModalWidget() self.test.assertIsNone(diag, "Dialog box could not be found")