def setupSignals(self): """ setupSignals() -> connect some things """ self.connect(self, qt.PYSIGNAL('RunChildApps'), self.runChildApps) self.connect(self.buttonStop, qt.SIGNAL('clicked()'), self, qt.SLOT('exec()')) self.connect(self.buttonClose, qt.SIGNAL('clicked()'), self, qt.SLOT('close()'))
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("New Package Priority")) self._window.setModal(True) #self._window.setMinimumSize(600, 400) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() table = qt.QGrid(2, vbox) table.setSpacing(10) table.show() label = qt.QLabel(_("Package Name:"), table) self._name = qt.QLineEdit(table) self._name.show() label = qt.QLabel(_("Channel Alias:"), table) self._alias = qt.QLineEdit(table) self._alias.setText("*") self._alias.show() label = qt.QLabel(_("Priority:"), table) self._priority = qt.QSpinBox(table) self._priority.setSteps(1, 10) self._priority.setRange(-100000,+100000) self._priority.show() sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) button = qt.QPushButton(_("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True) vbox.adjustSize() self._window.adjustSize()
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("New Target")) self._window.setModal(True) #self._window.setMinimumSize(600, 400) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() table = qt.QGrid(2, vbox) table.setSpacing(10) table.show() label = qt.QLabel(_("Target:"), table) self._target = qt.QLineEdit(table) self._target.setMaxLength(40) self._target.show() blank = qt.QWidget(table) label = qt.QLabel( _("Examples: \"pkgname\", \"pkgname = 1.0\" or " "\"pkgname <= 1.0\""), table) sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(bbox.tr("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button = qt.QPushButton(bbox.tr("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) vbox.adjustSize() self._window.adjustSize()
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("Package Priority")) self._window.setModal(True) #self._window.setMinimumSize(600, 400) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() self._vbox = vbox self._table = qt.QGrid(2, vbox) self._table.setSpacing(10) self._table.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Close"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("hide()")) self._vbox.adjustSize() self._window.adjustSize()
def main(args): app = qt.QApplication(sys.argv) win = testMcceWidget(6) app.setMainWidget(win) win.show() app.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) app.exec_loop()
def __init__(self, parent=None): qt.QDialog.__init__(self, parent) self.setIcon(getPixmap("smart")) self.setCaption(_("Change Summary")) self.setModal(True) self.setMinimumSize(600, 400) centerWindow(self) self._vbox = qt.QVBoxLayout(self) self._vbox.setMargin(10) self._vbox.setSpacing(10) self._label = qt.QLabel(self) self._vbox.addWidget(self._label) self._pv = QtPackageView(self) self._pv.getTreeView().header().hide() self._pv.setExpandPackage(True) self._pv.show() self._vbox.addWidget(self._pv) self._sizelabel = qt.QLabel("", self) self._vbox.addWidget(self._sizelabel) self._confirmbbox = qt.QHBox(self) self._confirmbbox.setSpacing(10) self._confirmbbox.layout().addStretch(1) self._vbox.addWidget(self._confirmbbox) self._cancelbutton = qt.QPushButton(_("Cancel"), self._confirmbbox) qt.QObject.connect(self._cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("reject()")) self._okbutton = qt.QPushButton(_("OK"), self._confirmbbox) qt.QObject.connect(self._okbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("accept()")) self._closebbox = qt.QHBox(self) self._closebbox.setSpacing(10) self._closebbox.layout().addStretch(1) self._vbox.addWidget(self._closebbox) self._closebutton = qt.QPushButton(_("Close"), self._closebbox) qt.QObject.connect(self._closebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()"))
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("New Channel")) self._window.setModal(True) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() self._vbox = vbox table = qt.QGrid(2, vbox) table.setSpacing(10) table.show() self._table = table label = qt.QLabel(_("Type:"), table) self._typevbox = qt.QVButtonGroup(table) self._typevbox.setFrameStyle(qt.QFrame.NoFrame) self._typevbox.show() sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) button = qt.QPushButton(_("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) self._ok = button self._ok.setEnabled(False)
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("Select Channels")) self._window.setModal(True) self._window.setMinimumSize(600, 400) layout = qt.QVBoxLayout(self._window) layout.setResizeMode(qt.QLayout.FreeResize) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() layout.addWidget(vbox) self._treeview = qt.QListView(vbox) self._treeview.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self._treeview.setAllColumnsShowFocus(True) self._treeview.show() self._treeview.addColumn("") self._treeview.addColumn(_("Alias")) self._treeview.addColumn(_("Type")) self._treeview.addColumn(_("Name")) bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) button = qt.QPushButton(_("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True)
def __init__(self, parent=None): self._fields = {} self._fieldn = 0 self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("Edit Channel")) self._window.setModal(True) layout = qt.QVBoxLayout(self._window) layout.setResizeMode(qt.QLayout.FreeResize) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() layout.addWidget(vbox) self._vbox = vbox self._table = qt.QGrid(2, vbox) self._table.setSpacing(10) self._table.show() sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) button = qt.QPushButton(_("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True)
def _create_qApp(): """ Only one qApp can exist at a time, so check before creating one """ if qt.QApplication.startingUp(): if DEBUG: print "Starting up QApplication" global qApp qApp = qt.QApplication( [" "] ) qt.QObject.connect( qApp, qt.SIGNAL( "lastWindowClosed()" ), qApp, qt.SLOT( "quit()" ) )
def __init__(self, parent=None): self._window = qt.QDialog(None) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("Priorities")) #self._window.setModal(True) self._window.setMinimumSize(600, 400) layout = qt.QVBoxLayout(self._window) layout.setResizeMode(qt.QLayout.FreeResize) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() layout.addWidget(vbox) self._treeview = qt.QListView(vbox) self._treeview.setAllColumnsShowFocus(True) self._treeview.show() qt.QObject.connect(self._treeview, qt.SIGNAL("itemRenamed(QListViewItem *, int, const QString &)"), self.itemRenamed) qt.QObject.connect(self._treeview, qt.SIGNAL("selectionChanged()"), self.selectionChanged) self._treeview.addColumn(_("Package Name")) self._treeview.addColumn(_("Channel Alias")) self._treeview.addColumn(_("Priority")) bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("New"), bbox) button.setEnabled(True) button.setIconSet(qt.QIconSet(getPixmap("crystal-add"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newPriority) self._newpriority = button button = qt.QPushButton(_("Delete"), bbox) button.setEnabled(False) button.setIconSet(qt.QIconSet(getPixmap("crystal-delete"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delPriority) self._delpriority = button button = qt.QPushButton(_("Close"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True) vbox.adjustSize()
def _create_qApp(): """ Only one qApp can exist at a time, so check before creating one """ if qt.QApplication.startingUp(): if DEBUG: print "Starting up QApplication" global qApp qApp = qt.QApplication([" "]) qt.QObject.connect(qApp, qt.SIGNAL("lastWindowClosed()"), qApp, qt.SLOT("quit()")) #remember that matplotlib created the qApp - will be used by show() _create_qApp.qAppCreatedHere = True
def __init__(self, parent=None): qt.QDialog.__init__(self, parent) self.setIcon(getPixmap("smart")) self.setCaption(_("Icon Legend")) layout = qt.QVBoxLayout(self) self._vbox = qt.QVBox(self) self._vbox.setMargin(10) self._vbox.setSpacing(10) layout.add(self._vbox) label = qt.QLabel("<b>" + _("The following icons are used to indicate\nthe current status of a package:") + "</b>", self._vbox) label.show() grid = qt.QGrid(2, self._vbox) grid.setSpacing(5) grid.setMargin(5) grid.show() for icon, legend in [ (getPixmap("package-install"), _("Marked for installation")), (getPixmap("package-reinstall"), _("Marked for re-installation")), (getPixmap("package-upgrade"), _("Marked for upgrade")), (getPixmap("package-downgrade"), _("Marked for downgrade")), (getPixmap("package-remove"), _("Marked for removal")), (getPixmap("package-available"), _("Not installed")), (getPixmap("package-new"), _("Not installed (new)")), (getPixmap("package-available-locked"), _("Not installed (locked)")), (getPixmap("package-installed"), _("Installed")), (getPixmap("package-installed-outdated"), _("Installed (upgradable)")), (getPixmap("package-installed-locked"), _("Installed (locked)")), (getPixmap("package-broken"), _("Broken")), ]: image = qt.QLabel("", grid) image.setPixmap(icon) image.show() label = qt.QLabel(legend, grid) label.show() self._buttonbox = qt.QHBox(self._vbox) self._buttonbox.setSpacing(10) self._buttonbox.layout().addStretch(1) self._buttonbox.show() self._closebutton = qt.QPushButton(_("Close"), self._buttonbox) self._closebutton.show() qt.QObject.connect(self._closebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("hide()"))
def __init__(self, parent=None): qt.QDialog.__init__(self, parent) self.setIcon(getPixmap("smart")) self.setCaption(_("Log")) self.setMinimumSize(400, 300) #self.setModal(True) layout = qt.QVBoxLayout(self) layout.setResizeMode(qt.QLayout.FreeResize) self._vbox = qt.QVBox(self) self._vbox.setMargin(10) self._vbox.setSpacing(10) self._vbox.show() layout.add(self._vbox) self._scrollview = BackgroundScrollView(self._vbox) self._scrollview.setVScrollBarMode(qt.QScrollView.AlwaysOn) self._scrollview.setFrameStyle(qt.QFrame.StyledPanel | qt.QFrame.Sunken) self._scrollview.show() self._textview = qt.QLabel(self._scrollview.viewport()) self._textview.setAlignment(qt.Qt.AlignTop) self._textview.setTextFormat(qt.Qt.LogText) self._textview.show() self._textview.adjustSize() self._textview.setEraseColor(self._scrollview.eraseColor()) self._buttonbox = qt.QHBox(self._vbox) self._buttonbox.setSpacing(10) self._buttonbox.layout().addStretch(1) self._buttonbox.show() self._clearbutton = qt.QPushButton(_("Clear"), self._buttonbox) self._clearbutton.show() qt.QObject.connect(self._clearbutton, qt.SIGNAL("clicked()"), self.clearText) self._closebutton = qt.QPushButton(_("Close"), self._buttonbox) self._closebutton.show() qt.QObject.connect(self._closebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("hide()")) self._closebutton.setDefault(True)
def show( mainloop=True ): """ Show all the figures and enter the qt main loop This should be the last line of your script """ for manager in Gcf.get_all_fig_managers(): manager.window.show() if DEBUG: print 'Inside show' figManager = Gcf.get_active() if figManager != None: figManager.canvas.draw() #if ( createQApp ): # qtapplication.setMainWidget( figManager.canvas ) if mainloop and createQApp: qt.QObject.connect( qtapplication, qt.SIGNAL( "lastWindowClosed()" ), qtapplication, qt.SLOT( "quit()" ) ) qtapplication.exec_loop()
def __init__(self, ctrl, argv=None): QtInterface.__init__(self, ctrl, argv) self._changeset = None self._window = qt.QMainWindow() self._window.setCaption("Smart Package Manager %s" % VERSION) centerWindow(self._window) self._window.setMinimumSize(640, 480) app.connect(app, qt.SIGNAL('lastWindowClosed()'), app, qt.SLOT('quit()')) self._undo = [] self._redo = [] globals = {"self": self, "qt": qt} group = qt.QActionGroup(self._window, "Actions") self._actions = compileActions(group, ACTIONS, globals) class ToggleAction(qt.QAction): def __init__(self, group, name, label): qt.QAction.__init__(self, group, name) self.setToggleAction(True) self.setMenuText(label.replace("&","&&")) self._name = name def connect(self, signal, callback, userdata): self._callback = callback self._userdata = userdata qt.QObject.connect(self, qt.SIGNAL(signal), self.slot) def slot(self): self._callback(self._userdata) self._filters = {} for name, label in [("hide-non-upgrades", _("Hide Non-upgrades")), ("hide-installed", _("Hide Installed")), ("hide-uninstalled", _("Hide Uninstalled")), ("hide-unmarked", _("Hide Unmarked")), ("hide-unlocked", _("Hide Unlocked")), ("hide-requested", _("Hide Requested")), ("hide-old", _("Hide Old"))]: act = ToggleAction(None, name, label) act.connect("activated()", self.toggleFilter, name) self._actions[name] = act treestyle = sysconf.get("package-tree") for name, label in [("groups", _("Groups")), ("channels", _("Channels")), ("channels-groups", _("Channels & Groups")), ("none", _("None"))]: act = ToggleAction(group, "tree-style-"+name, label) if name == treestyle: act.setOn(True) act.connect("activated()", self.setTreeStyle, name) self._actions["tree-style-"+name] = act self._menubar = self._window.menuBar() for MENU in MENUBAR: def insertmenu(menubar, menu): item = menu[0] action = self._actions[item] m = qt.QPopupMenu(menubar) text = action.menuText() menubar.insertItem(text, m) for item in menu[1]: if isinstance(item, tuple): insertmenu(m, item) elif item: action = self._actions[item] #i = qt.QPopupMenu(m) #text = action.menuText() #m.insertItem(text, i) action.addTo(m) else: m.insertSeparator() insertmenu(self._menubar, MENU) self._toolbar = qt.QToolBar(self._window) for TOOL in TOOLBAR: def inserttool(toolbar, tool): if tool: action = self._actions[tool] #b = qt.QToolButton(toolbar, TOOL) #b.setTextLabel(action.toolTip()) pixmap = getPixmap(TOOLBARICONS[tool]) #b.setIconSet(qt.QIconSet(pixmap)) action.setIconSet(qt.QIconSet(pixmap)) action.addTo(toolbar) else: toolbar.addSeparator() inserttool(self._toolbar, TOOL) #self._window.add_accel_group(self._ui.get_accel_group()) self._actions["exec-changes"].setAccel(qt.QKeySequence("Ctrl+C")) self._actions["find"].setAccel(qt.QKeySequence("Ctrl+F")) self._actions["expand-all"].setAccel(qt.QKeySequence("Ctrl+O")) self._actions["collapse-all"].setAccel(qt.QKeySequence("Ctrl+W")) self._actions["summary-window"].setAccel(qt.QKeySequence("Ctrl+S")) self._actions["exec-changes"].setEnabled(False) self._actions["clear-changes"].setEnabled(False) self._actions["undo"].setEnabled(False) self._actions["redo"].setEnabled(False) # Search bar self._searchbar = qt.QToolBar(self._window) self._searchbar.hide() label = qt.QLabel(_("Search:"), self._searchbar) label.show() self._searchentry = qt.QLineEdit(self._searchbar) qt.QObject.connect(self._searchentry, qt.SIGNAL("returnPressed()"), self.refreshPackages) self._searchentry.show() button = qt.QPushButton(self._searchbar) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.refreshPackages) pixmap = getPixmap("crystal-search") button.setIconSet(qt.QIconSet(pixmap)) button.show() buttongroup = qt.QButtonGroup(self._searchbar) buttongroup.hide() self._searchname = qt.QRadioButton(_("Automatic"), self._searchbar) self._searchname.setChecked(True) qt.QObject.connect(self._searchname, qt.SIGNAL("clicked()"), self.refreshPackages) buttongroup.insert(self._searchname) self._searchname.show() self._searchdesc = qt.QRadioButton(_("Description"), self._searchbar) self._searchdesc.setChecked(False) qt.QObject.connect(self._searchdesc, qt.SIGNAL("clicked()"), self.refreshPackages) self._searchdesc.show() buttongroup.insert(self._searchdesc) # Packages and information self._splitter = qt.QSplitter(qt.Qt.Vertical, self._window) self._window.setCentralWidget(self._splitter) self._pv = QtPackageView(self._splitter) self._pv.show() self._pi = QtPackageInfo(self._splitter) self._pi.show() qt.QObject.connect(self._pv, qt.PYSIGNAL("packageSelected"), self._pi.setPackage) qt.QObject.connect(self._pv, qt.PYSIGNAL("packageActivated"), self.actOnPackages) qt.QObject.connect(self._pv, qt.PYSIGNAL("packagePopup"), self.packagePopup) self._status = self._window.statusBar() self._status.show() self._legend = QtLegend(self._window)
qt.QObject.connect(self.QuitButton, qt.SIGNAL('clicked()'), self.quit) # Create a root histogram. self.hist = ROOT.TH1F("pipo", "pipo", 100, 0, 100) # Create the main TQtWidget (using sip to get the pointer to the central widget). self.Address = sip.unwrapinstance(self.CentralWidget) self.Canvas = ROOT.TQtWidget(sip.voidptr(self.Address).ascobject()) # Place the TQtWidget in the main grid layout and draw the histogram. self.Layout.addWidget( sip.wrapinstance(ROOT.AddressOf(self.Canvas)[0], qt.QWidget), 0, 0) self.hist.Draw() def quit(self): print 'Bye bye...' self.close() if __name__ == '__main__': application = qt.qApp terminator = ROOT.TQtRootSlot.CintSlot() termAddress = sip.wrapinstance(ROOT.AddressOf(terminator)[0], qt.QObject) qt.QObject.connect(application, qt.SIGNAL("lastWindowClosed()"), termAddress, qt.SLOT("Terminate()")) w = window() w.show() ROOT.gApplication.Run(1) print 'Bye forever!'
def __init__(self, parent=None): self._changed = False self._window = qt.QDialog(None) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("Channels")) self._window.setModal(True) self._window.setMinimumSize(600, 400) layout = qt.QVBoxLayout(self._window) layout.setResizeMode(qt.QLayout.FreeResize) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() layout.addWidget(vbox) self._treeview = qt.QListView(vbox) self._treeview.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self._treeview.setAllColumnsShowFocus(True) self._treeview.setSelectionMode(qt.QListView.Single) self._treeview.show() qt.QObject.connect(self._treeview, qt.SIGNAL("selectionChanged()"), self.selectionChanged) qt.QObject.connect( self._treeview, qt.SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"), self.doubleClicked) self._treeview.addColumn("") self._treeview.addColumn(_("Pri")) self._treeview.addColumn(_("Alias")) self._treeview.addColumn(_("Type")) self._treeview.addColumn(_("Name")) bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("New"), bbox) button.setIconSet(qt.QIconSet(getPixmap("crystal-add"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newChannel) self._newchannel = button button = qt.QPushButton(_("Delete"), bbox) button.setEnabled(False) button.setIconSet(qt.QIconSet(getPixmap("crystal-delete"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delChannel) self._delchannel = button button = qt.QPushButton(_("Edit"), bbox) button.setEnabled(False) button.setIconSet(qt.QIconSet(getPixmap("crystal-edit"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.editChannel) self._editchannel = button button = qt.QPushButton(_("Close"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True) vbox.adjustSize()
acq_params.take_dark_current = ( self.dialog_layout_widget.force_dark_cbx.isOn() ) acq_params.skip_existing_images = ( self.dialog_layout_widget.skip_existing_images_cbx.isOn() ) self.emit( qt.PYSIGNAL("continue_clicked"), (self.sample_items, self.checked_items) ) self.accept() def cancel_button_click(self): # for item, run_number in self.item_run_number_list: # item.get_model().set_number(run_number) # path_template = item.get_model().get_path_template() # path_template.run_number = run_number self.reject() if __name__ == "__main__": a = qt.QApplication(sys.argv) qt.QObject.connect(a, qt.SIGNAL("lastWindowClosed()"), a, qt.SLOT("quit()")) w = ConfirmDialog() # a.setMainWidget(w) w.setModal(True) w.show() a.exec_loop()
logging.getLogger("user_level_log").\ info("Incorrect count time value") return data_collections # Called by the owning widget (task_toolbox_widget) when # one or several centred positions are selected. def centred_position_selection(self, positions): self._selected_positions = positions if len(self._current_selected_items) == 1 and len(positions) == 1: item = self._current_selected_items[0] pos = positions[0] if isinstance(pos, shape_history.Point): if isinstance(item, queue_item.XRFScanQueueItem): cpos = pos.get_centred_positions()[0] snapshot = self._shape_history.get_snapshot( [pos.qub_point]) cpos.snapshot_image = snapshot item.get_model().centred_position = cpos if __name__ == "__main__": app = qt.QApplication(sys.argv) qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) widget = CreateXRFScanWidget() app.setMainWidget(widget) widget.show() app.exec_loop()
"""Main program file, used to set up paths, import globals into app namespace etc...""" __revision__ = '$Id$' import sys, locale import os.path as op import qt basepath = op.dirname(op.dirname(op.abspath(sys.argv[0]))) __paths = {} for subdir in ('bin', 'doc', 'lib', 'share'): __paths[subdir] = op.join(basepath, subdir) sys.path.append(__paths['lib']) import jt_const jt_const.PATHS = __paths del __paths locale.setlocale(locale.LC_ALL, '') if __name__ == '__main__': import qjt_main a = qt.QApplication(sys.argv) qt.QObject.connect(a, qt.SIGNAL('lastWindowClosed()'), a, qt.SLOT('quit()')) w = qjt_main.MainForm() a.setMainWidget(w) w.show() a.exec_loop()
def compileActions(group, actions, globals): newactions = {} for action in actions: #if len(action) > 5: # action = list(action) # code = compile(action[5], "<callback>", "exec") # def callback(action, code=code, globals=globals): # globals["action"] = action # exec code in globals # action[5] = callback act = qt.QAction(group, action[0]) act.setText(action[0]) act.setMenuText(action[2].replace("_","&")) if len(action) > 4: act.setToolTip(action[4]) if len(action) > 5 and type(action[5]) is not str: qt.QObject.connect(act, qt.SIGNAL("activated()") , action[5]) if action[0] == "find": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.toggleSearch) if action[0] == "update-selected-channels": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.updateSelected) if action[0] == "update-channels": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.updateChannels) if action[0] == "rebuild-cache": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.rebuildCache) if action[0] == "check-installed-packages": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.checkInstalledPackages) if action[0] == "check-uninstalled-packages": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.checkUninstalledPackages) if action[0] == "check-all-packages": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.checkAllPackages) if action[0] == "upgrade-all": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.upgradeAll) if action[0] == "fix-all-problems": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.fixAllProblems) if action[0] == "exec-changes": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.applyChanges) if action[0] == "undo": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.undo) if action[0] == "redo": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.redo) if action[0] == "clear-changes": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.clearChanges) if action[0] == "expand-all": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.expandPackages) if action[0] == "collapse-all": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.collapsePackages) if action[0] == "edit-channels": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.editChannels) if action[0] == "edit-mirrors": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.editMirrors) if action[0] == "edit-flags": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.editFlags) if action[0] == "edit-priorities": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.editPriorities) if action[0] == "summary-window": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.showChanges) if action[0] == "log-window": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.showLog) if action[0] == "legend-window": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.showLegend) if action[0] == "about": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), self.showAbout) if action[0] == "quit": #HACK self = globals["self"] qt.QObject.connect(act, qt.SIGNAL("activated()"), app, qt.SLOT("quit()")) group.add(act) #newactions[action[0]] = tuple(action) newactions[action[0]] = act return newactions
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("New Channel")) self._window.setModal(True) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() table = qt.QGrid(1, vbox) table.setSpacing(10) table.show() label = qt.QLabel(_("Method:"), table) methodvbox = qt.QVButtonGroup(table) methodvbox.show() sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) button = qt.QPushButton(_("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) self._ok = button self._ok.setEnabled(False) self._method = None for method, descr in [ ("manual", _("Provide channel information")), ("descriptionpath", _("Read channel description from local path")), ("descriptionurl", _("Read channel description from URL")), ("detectmedia", _("Detect channel in media (CDROM, DVD, etc)")), ("detectpath", _("Detect channel in local path")) ]: if not self._method: self._method = method radio = qt.QRadioButton(descr, methodvbox, method) qt.QObject.connect(radio, qt.SIGNAL("clicked()"), self.ok) act = RadioAction(radio, method, descr) act.connect(self, "_method", method) radio.show() methodvbox.adjustSize() vbox.adjustSize() self._window.adjustSize()
def __init__(self, parent=None): self._window = qt.QDialog(None) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("Flags")) self._window.setModal(True) self._window.setMinimumSize(600, 400) layout = qt.QVBoxLayout(self._window) layout.setResizeMode(qt.QLayout.FreeResize) topvbox = qt.QVBox(self._window) topvbox.setMargin(10) topvbox.setSpacing(10) topvbox.show() layout.addWidget(topvbox) tophbox = qt.QHBox(topvbox) tophbox.setSpacing(20) tophbox.show() # Left side vbox = qt.QVGroupBox(tophbox) vbox.setInsideSpacing(10) vbox.show() self._flagsview = qt.QListView(vbox) self._flagsview.show() qt.QObject.connect(self._flagsview, qt.SIGNAL("selectionChanged()"), self.flagSelectionChanged) self._flagsview.addColumn(_("Flags")) bbox = qt.QHBox(vbox) bbox.setMargin(5) bbox.setSpacing(10) bbox.show() button = qt.QPushButton(_("New"), bbox) button.setEnabled(True) button.setIconSet(qt.QIconSet(getPixmap("crystal-add"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newFlag) self._newflag = button button = qt.QPushButton(_("Delete"), bbox) button.setEnabled(False) button.setIconSet(qt.QIconSet(getPixmap("crystal-delete"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delFlag) self._delflag = button # Right side vbox = qt.QVGroupBox(tophbox) vbox.setInsideSpacing(10) vbox.show() self._targetsview = qt.QListView(vbox) self._targetsview.show() qt.QObject.connect(self._targetsview, qt.SIGNAL("selectionChanged()"), self.targetSelectionChanged) self._targetsview.addColumn(_("Targets")) bbox = qt.QHBox(vbox) bbox.setMargin(5) bbox.setSpacing(10) bbox.show() button = qt.QPushButton(_("New"), bbox) button.setEnabled(False) button.setIconSet(qt.QIconSet(getPixmap("crystal-add"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.newTarget) self._newtarget = button button = qt.QPushButton(_("Delete"), bbox) button.setEnabled(False) button.setIconSet(qt.QIconSet(getPixmap("crystal-delete"))) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.delTarget) self._deltarget = button # Bottom sep = qt.QFrame(topvbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(topvbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Close"), bbox) button.show() qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True)
self.allLogs.append(log) exits = [child[2].isRunning() for child in self.child_apps] if not sum(exits): self.close() def closeEvent(self, event): """ closeEvent(event) -> write log entries to stdout and accept """ for line in self.allLogs: print line[:-1] event.accept() if __name__ == '__main__': try: scripts = tws, helper, collector = sys.argv[1:4] scripts = zip(('Ib Tws', 'Gui Helper', 'Collector'), scripts) except (ValueError, ): print 'Usage: %s tws_cmd helper_cmd collector_cmd' % (__file__, ) sys.exit(1) app = qt.QApplication([]) win = DataCollectorMainForm(parent=None, apps=scripts) app.connect(app, qt.SIGNAL('lastWindowClosed()'), app, qt.SLOT('quit()')) app.setMainWidget(win) win.show() app.exec_loop()