Ejemplo n.º 1
0
class BaseWorksEntryFrame(QFrame):
    def __init__(self, parent, name='BaseWorksEntryFrame'):
        QFrame.__init__(self, parent, name)
        margin = 0
        space = 1
        self.grid = QGridLayout(self, 6, 1, margin, space)
        
        self.worktype_lbl = QLabel('Work Type', self)
        self.worktype_entry = KLineEdit('website', self)
        self.title_lbl = QLabel('Title', self)
        self.title_entry = KLineEdit('', self)
        self.url_lbl = QLabel('Url', self)
        self.url_entry = KLineEdit('', self)

        row = 0
        for widget in [self.worktype_lbl, self.worktype_entry,
                       self.title_lbl, self.title_entry,
                       self.url_lbl, self.url_entry]:
            self.grid.addWidget(widget, row, 0)
            row += 1
            
    def get_data(self):
        wtype = str(self.worktype_entry.text())
        title = str(self.title_entry.text())
        url = str(self.url_entry.text())
        return dict(title=title, url=url, type=wtype)

    def set_data(self, data):
        self.title_entry.setText(data['title'])
        self.url_entry.setText(data['url'])
        wtype = data['type']
        if wtype is None:
            wtype = 'website'
        self.worktype_entry.setText(wtype)
Ejemplo n.º 2
0
 def __init__(self, parent, umlmachines, name='InstallerWidget'):
     QWidget.__init__(self, parent, name)
     self.resize(600, 600)
     self.app = get_application_pointer()
     self.conn = self.app.conn
     self.umlmachines = umlmachines
     self.machine = self.umlmachines.current
     self.current_machine_process = 'start'
     self.current_profile = None
     self.current_trait = None
     self.traitlist = []
     self.curenv = CurrentEnvironment(self.conn, self.machine)
     self.curenv['current_profile'] = 'None'
     self.curenv['current_trait'] = 'None'
     self.curenv['current_machine_process'] = self.current_machine_process
     self.timer = QTimer(self)
     self.connect(self.timer, SIGNAL('timeout()'), self.update_progress)
     self.timer.startTimer(1000)
     self.grid = QGridLayout(self, 4, 1, 5, 7)
     self.main_label = QLabel(self)
     self.main_label.setText(self._msg())
     self.grid.addWidget(self.main_label, 0, 0)
     self.profile_progress_lbl = QLabel(self)
     self.grid.addWidget(self.profile_progress_lbl, 1, 0)
     self.profile_progress = KProgress(self)
     self.grid.addWidget(self.profile_progress, 2, 0)
     self.logview = LogBrowser(self, '/tmp/uml-installer.log')
     self.grid.addWidget(self.logview, 3, 0)
     #self.console_view = StdOutBrowser(self)
     #self.console_view = KTextBrowser(self)
     #self.grid.addWidget(self.console_view, 4, 0)
     self.console_text = ''
Ejemplo n.º 3
0
class GusHardwareOptions(QWidget):
    def __init__(self, parent, name="GusHardwareOptions"):
        QWidget.__init__(self, parent, name)
        numrows = 2
        numcols = 3
        margin = 0
        space = 1
        self.grid = QGridLayout(self, numrows, numcols, margin, space, "GusHardwareOptionsLayout")
        self.base_box = ConfigSpinWidget(self, "I/O address", max=1000)
        self.grid.addWidget(self.base_box, 0, 0)
        self.irq1_box = ConfigSpinWidget(self, "IRQ 1", min=3, max=15)
        self.grid.addWidget(self.irq1_box, 0, 1)
        self.irq2_box = ConfigSpinWidget(self, "IRQ 2", min=3, max=15)
        self.grid.addWidget(self.irq2_box, 1, 1)
        self.dma1_box = ConfigSpinWidget(self, "DMA 1")
        self.grid.addWidget(self.dma1_box, 0, 2)
        self.dma2_box = ConfigSpinWidget(self, "DMA 2")
        self.grid.addWidget(self.dma2_box, 1, 2)

    def get_config_options(self):
        opts = {}
        opts["gusbase"] = self.base_box.get_config_option()
        opts["irq1"] = self.irq1_box.get_config_option()
        opts["irq2"] = self.irq2_box.get_config_option()
        opts["dma1"] = self.dma1_box.get_config_option()
        opts["dma2"] = self.dma2_box.get_config_option()

        return opts

    def set_config_options(self, opts):
        self.base_box.set_config_option(opts["gusbase"])
        self.irq1_box.set_config_option(opts["irq1"])
        self.irq2_box.set_config_option(opts["irq2"])
        self.dma1_box.set_config_option(opts["dma1"])
        self.dma2_box.set_config_option(opts["dma2"])
Ejemplo n.º 4
0
 def __init__(self, parent, fields, text=None, name='EditableRecord'):
     QGridLayout.__init__(self, parent, len(fields) + 2, 2, 1, -1, name)
     self.fields = fields
     self.entries = {}
     self._setupfields(parent)
     self.setSpacing(7)
     self.setMargin(10)
     self.addMultiCellWidget(QLabel(text, parent), 0, 0, 0, 1)
Ejemplo n.º 5
0
 def __init__(self, parent, text='', name='LabeledProgress'):
     QWidget.__init__(self, parent, name)
     self.grid = QGridLayout(self, 2, 1, 5, 7)
     self.label = QLabel(self)
     if text:
         self.label.setText(text)
     self.progressbar = SimpleProgress(self)
     self.grid.addWidget(self.label, 0, 0)
     self.grid.addWidget(self.progressbar, 1, 0)
Ejemplo n.º 6
0
 def __init__(self, parent, fields, text=None, name='SimpleRecord'):
     if text is None:
         text = '<b>insert a simple record</b>'
     QGridLayout.__init__(self, parent, len(fields) + 1, 2, 1, -1, name)
     self.fields = fields
     self.entries = {}
     self._setupfields(parent)
     self.setSpacing(7)
     self.setMargin(10)
     self.addMultiCellWidget(QLabel(text, parent), 0, 0, 0, 1)
Ejemplo n.º 7
0
 def __init__(self, parent, fields, text=None, name='SimpleRecord'):
     if text is None:
         text = '<b>insert a simple record</b>'
     QGridLayout.__init__(self, parent, len(fields) + 1, 2, 1, -1, name)
     self.fields = fields
     self.entries = {}
     self._setupfields(parent)
     self.setSpacing(7)
     self.setMargin(10)
     self.addMultiCellWidget(QLabel(text, parent), 0, 0, 0, 1)
Ejemplo n.º 8
0
class IntroPage(BaseConfigWidget):
    def __init__(self, parent, name='IntroPage'):
        BaseConfigWidget.__init__(self, parent, name=name)
        numrows = 2
        numcols = 1
        margin = 5
        space = 7
        self.grid = QGridLayout(self, numrows, numcols,
                                margin, space, 'IntroPageLayout')
        lbl = QLabel(intro, self)
        self.grid.addWidget(lbl, 0, 0)
Ejemplo n.º 9
0
 def __init__(self, parent, cfg, group, keys):
     cfg.setGroup(group)
     QGridLayout.__init__(self, parent, len(keys), 2)
     self.entries = {}.fromkeys(keys)
     row = 0
     for k in keys:
         self.addWidget(QLabel(k, parent), row, 0)
         entry = KLineEdit(parent)
         self.addWidget(entry, row, 1)
         self.entries[k] = entry
         entry.setText(cfg.readEntry(k))
         row += 1
Ejemplo n.º 10
0
 def setupPlottingFrame(self, parent=None):
   if not parent:
     parent = self.layout
   self.plottingFrameWidget = QWidget()
   self.plottingFrameLayout = QGridLayout()
   self.plottingFrameWidget.setLayout(self.plottingFrameLayout)
   self._multiVolumeIntensityChart = MultiVolumeIntensityChartView()
   self.popupChartButton = QPushButton("Undock chart")
   self.popupChartButton.setCheckable(True)
   self.plottingFrameLayout.addWidget(self._multiVolumeIntensityChart.chartView)
   self.plottingFrameLayout.addWidget(self.popupChartButton)
   parent.addWidget(self.plottingFrameWidget)
Ejemplo n.º 11
0
 def __init__(self, parent, fields, text=None, name='EditableRecordFrame'):
     QFrame.__init__(self, parent, name)
     numrows = len(fields) + 2
     numcols = 2
     self.grid = QGridLayout(self, numrows, numcols, 1, -1, name)
     self.fields = fields
     self.entries = {}
     self._setupfields()
     self.grid.setSpacing(7)
     self.grid.setMargin(10)
     self.text_label = QLabel(text, self)
     self.grid.addMultiCellWidget(self.text_label, 0, 0, 0, 1)
Ejemplo n.º 12
0
 def __init__(self, parent, fields, text=None, record=None, name=None):
     print 'record, name', record, name
     if name is None:
         print 'I need a name', record
         raise Exception, 'name needed in SimpleRecord'
     QGridLayout.__init__(self, parent, len(fields) + 1, 2, 1, -1, name)
     self.fields = fields
     self.entries = {}
     #self._setupfields(parent)
     self.setSpacing(7)
     self.setMargin(10)
     self.record = record
     self._refbuttons = {}
     self._setupfields(parent)
Ejemplo n.º 13
0
class SoundBlasterHardwareOptions(QWidget):
    def __init__(self, parent, name="SoundBlasterHardwareOptions"):
        QWidget.__init__(self, parent, name)
        numrows = 2
        numcols = 3
        margin = 0
        space = 1
        self.grid = QGridLayout(self, numrows, numcols, margin, space, "SoundBlasterHardwareOptionsLayout")
        self.base_box = ConfigSpinWidget(self, "I/O address", max=1000)
        self.grid.addWidget(self.base_box, 0, 0)
        self.irq_box = ConfigSpinWidget(self, "IRQ", min=3, max=15)
        self.grid.addWidget(self.irq_box, 1, 0)
        self.dma_box = ConfigSpinWidget(self, "DMA")
        self.grid.addWidget(self.dma_box, 0, 2)
        self.hdma_box = ConfigSpinWidget(self, "High DMA")
        self.grid.addWidget(self.hdma_box, 1, 2)

    def get_config_options(self):
        opts = {}
        opts["sbbase"] = self.base_box.get_config_option()
        opts["irq"] = self.irq_box.get_config_option()
        opts["dma"] = self.dma_box.get_config_option()
        opts["hdma"] = self.hdma_box.get_config_option()
        return opts

    def set_config_options(self, opts):
        self.base_box.set_config_option(opts["sbbase"])
        self.irq_box.set_config_option(opts["irq"])
        self.dma_box.set_config_option(opts["dma"])
        self.hdma_box.set_config_option(opts["hdma"])
Ejemplo n.º 14
0
class TestConfigTab(QWidget):
    def __init__(self, parent, name='TestConfigTab'):
        QWidget.__init__(self, parent, name)
        self.grid = QGridLayout(self, 2, 1, 0, 1, 'TestConfigTabLayout')
        self.textbrowser = KTextBrowser(self)
        self.grid.addWidget(self.textbrowser, 0, 0)
        self.button = KPushButton(self)
        self.button.setText('test get_config')
        self.grid.addWidget(self.button, 1, 0)
        
    def set_config(self, cfg):
        tfile = StringIO()
        cfg.write(tfile)
        tfile.seek(0)
        text = tfile.read()
        self.textbrowser.setText(text)
Ejemplo n.º 15
0
class LabeledProgress(QWidget):
    def __init__(self, parent, text='', name='LabeledProgress'):
        QWidget.__init__(self, parent, name)
        self.grid = QGridLayout(self, 2, 1, 5, 7)
        self.label = QLabel(self)
        if text:
            self.label.setText(text)
        self.progressbar = SimpleProgress(self)
        self.grid.addWidget(self.label, 0, 0)
        self.grid.addWidget(self.progressbar, 1, 0)

    def setTotalSteps(self, total):
        self.progressbar.setTotalSteps(total)

    def step_progress(self, *args):
        self.progressbar.step_progress(*args)
Ejemplo n.º 16
0
    def __init__(self, parent, name='BaseGuestDataFrame'):
        QFrame.__init__(self, parent, name)
        self.guestid = None
        numrows = 2
        numcols = 2
        margin = 0
        space = 1
        self.grid = QGridLayout(self, numrows, numcols,
                                margin, space, 'BaseGuestDataLayout')
        self.app = get_application_pointer()


        self.fname_lbl = QLabel('First Name', self)
        self.fname_entry = KLineEdit('', self)

        self.grid.addWidget(self.fname_lbl, 0, 0)
        self.grid.addWidget(self.fname_entry, 1, 0)

        self.lname_lbl = QLabel('Last Name', self)
        self.lname_entry = KLineEdit('', self)

        self.grid.addWidget(self.lname_lbl, 0, 1)
        self.grid.addWidget(self.lname_entry, 1, 1)

        self.title_lbl = QLabel('Title', self)
        self.title_entry = KLineEdit('', self)

        self.grid.addMultiCellWidget(self.title_lbl, 2, 2, 0, 1)
        self.grid.addMultiCellWidget(self.title_entry, 3, 3, 0, 1)

        self.desc_lbl = QLabel('Description', self)
        self.desc_entry = KTextEdit(self, 'description_entry')

        self.grid.addMultiCellWidget(self.desc_lbl, 4, 4, 0, 1)
        self.grid.addMultiCellWidget(self.desc_entry, 5, 7, 0, 1)
    def setup(self):
        self.widget = QWidget()
        layout = QGridLayout()
        self.widget.setLayout(layout)
        self.layout.addWidget(self.widget)
        self.widget.show()
        self.layout = layout

        self.setupInputFrame()
        self.setupFrameControlFrame()
        self.setupAdditionalFrames()
        self.setupPlottingFrame()

        self.setFramesEnabled(False)

        self.timer = QTimer()
        self.timer.setInterval(50)

        self.setupConnections()

        # initialize slice observers (from DataProbe.py)
        # keep list of pairs: [observee,tag] so they can be removed easily
        self.styleObserverTags = []
        # keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
        self.sliceWidgetsPerStyle = {}
        self.refreshObservers()
Ejemplo n.º 18
0
 def setupPlottingFrame(self, parent=None):
   self.plotFrame = ctk.ctkCollapsibleButton()
   self.plotFrame.text = "Plotting"
   self.plotFrame.collapsed = 0
   plotFrameLayout = QGridLayout(self.plotFrame)
   self.layout.addWidget(self.plotFrame)
   qSlicerMultiVolumeExplorerSimplifiedModuleWidget.setupPlottingFrame(self, parent=plotFrameLayout)
Ejemplo n.º 19
0
class LabeledProgress(QWidget):
    def __init__(self, parent, text='', name='LabeledProgress'):
        QWidget.__init__(self, parent, name)
        self.grid = QGridLayout(self, 2, 1, 5, 7)
        self.label = QLabel(self)
        if text:
            self.label.setText(text)
        self.progressbar = SimpleProgress(self)
        self.grid.addWidget(self.label, 0, 0)
        self.grid.addWidget(self.progressbar, 1, 0)
                  
    def setTotalSteps(self, total):
        self.progressbar.setTotalSteps(total)

    def step_progress(self, *args):
        self.progressbar.step_progress(*args)
Ejemplo n.º 20
0
 def __init__(self, parent, umlmachines, name="InstallerWidget"):
     QWidget.__init__(self, parent, name)
     self.resize(600, 600)
     self.app = get_application_pointer()
     self.conn = self.app.conn
     self.umlmachines = umlmachines
     self.machine = self.umlmachines.current
     self.current_machine_process = "start"
     self.current_profile = None
     self.current_trait = None
     self.traitlist = []
     self.curenv = CurrentEnvironment(self.conn, self.machine)
     self.curenv["current_profile"] = "None"
     self.curenv["current_trait"] = "None"
     self.curenv["current_machine_process"] = self.current_machine_process
     self.timer = QTimer(self)
     self.connect(self.timer, SIGNAL("timeout()"), self.update_progress)
     self.timer.startTimer(1000)
     self.grid = QGridLayout(self, 4, 1, 5, 7)
     self.main_label = QLabel(self)
     self.main_label.setText(self._msg())
     self.grid.addWidget(self.main_label, 0, 0)
     self.profile_progress_lbl = QLabel(self)
     self.grid.addWidget(self.profile_progress_lbl, 1, 0)
     self.profile_progress = KProgress(self)
     self.grid.addWidget(self.profile_progress, 2, 0)
     self.logview = LogBrowser(self, "/tmp/uml-installer.log")
     self.grid.addWidget(self.logview, 3, 0)
     # self.console_view = StdOutBrowser(self)
     # self.console_view = KTextBrowser(self)
     # self.grid.addWidget(self.console_view, 4, 0)
     self.console_text = ""
Ejemplo n.º 21
0
class DosboxPathPage(BaseConfigWidget):
    def __init__(self, parent, name='DosboxPathPage'):
        BaseConfigWidget.__init__(self, parent, name=name)
        numrows = 2
        numcols = 1
        margin = 5
        space = 7
        self.grid = QGridLayout(self, numrows, numcols,
                                margin, space, 'DosboxPathPageLayout')
        lbl = QLabel(dosbox_path_lbl, self)
        lbl.setFrameStyle(lbl.Panel + lbl.Sunken)
        #lbl.setFrameStyle(lbl.Raised)
        self.grid.addWidget(lbl, 0, 0)
        self.dosbox_path_entry = ConfigKURLSelectWidget(self, 'Path to main dosbox area',
                                                        filetype='dir')
        self.grid.addWidget(self.dosbox_path_entry, 1, 0)
Ejemplo n.º 22
0
 def __init__(self, server=None):
     QDialog.__init__(self, None)
     decorateWindow(self, i18n('Select a ruleset'))
     self.buttonBox = KDialogButtonBox(self)
     self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                       | QDialogButtonBox.Ok)
     self.buttonBox.accepted.connect(self.accept)
     self.buttonBox.rejected.connect(self.reject)
     self.cbRuleset = ListComboBox(Ruleset.selectableRulesets(server))
     self.grid = QGridLayout()  # our child SelectPlayers needs this
     self.grid.setColumnStretch(0, 1)
     self.grid.setColumnStretch(1, 6)
     vbox = QVBoxLayout(self)
     vbox.addLayout(self.grid)
     vbox.addWidget(self.cbRuleset)
     vbox.addWidget(self.buttonBox)
Ejemplo n.º 23
0
 def __init__(self, parent, cfg):
     cfg.setGroup('pgpool')
     keys = ['command', 'connection_life_time', 'max_pool', 'num_init_children',
             'port', 'usepgpool']
     QGridLayout.__init__(self, parent, len(keys), 2)
     self.entries = {}.fromkeys(keys)
     row = 0
     for k in keys[:-1]:
         self.addWidget(QLabel(k, parent), row, 0)
         entry = KLineEdit(parent)
         self.addWidget(entry, row, 1)
         self.entries[k] = entry
         row += 1
     self.addWidget(QLabel('usepgpool', parent), row, 0)
     entry = QCheckBox('usepgpool', parent)
     self.addWidget(entry, row, 1)
     self.entries['usepgpool'] = entry
Ejemplo n.º 24
0
 def __init__(self, parent, name='TestConfigTab'):
     QWidget.__init__(self, parent, name)
     self.grid = QGridLayout(self, 2, 1, 0, 1, 'TestConfigTabLayout')
     self.textbrowser = KTextBrowser(self)
     self.grid.addWidget(self.textbrowser, 0, 0)
     self.button = KPushButton(self)
     self.button.setText('test get_config')
     self.grid.addWidget(self.button, 1, 0)
Ejemplo n.º 25
0
 def __init__(self, parent, text='', name='LabeledProgress'):
     QWidget.__init__(self, parent, name)
     self.grid = QGridLayout(self, 2, 1, 5, 7)
     self.label = QLabel(self)
     if text:
         self.label.setText(text)
     self.progressbar = SimpleProgress(self)
     self.grid.addWidget(self.label, 0, 0)
     self.grid.addWidget(self.progressbar, 1, 0)
Ejemplo n.º 26
0
 def __init__(self, parent):
     QButtonGroup.__init__(self, parent, "SeleccionMultiple")
     self.setGeometry(QRect(110, 80, 170, 121))
     self.setColumnLayout(0, Qt.Vertical)
     self.layout().setSpacing(6)
     self.layout().setMargin(11)
     self.layout = QGridLayout(self.layout(), 2)
     self.__row = 0
     self.__col = 0
Ejemplo n.º 27
0
 def __init__(self, client, parent=None):
     QDialog.__init__(self, parent)
     decorateWindow(self, i18n('Choose'))
     self.setObjectName('ClientDialog')
     self.client = client
     self.layout = QGridLayout(self)
     self.progressBar = QProgressBar()
     self.progressBar.setMinimumHeight(25)
     self.timer = QTimer()
     if not client.game.autoPlay:
         self.timer.timeout.connect(self.timeout)
     self.deferred = None
     self.buttons = []
     self.setWindowFlags(Qt.SubWindow | Qt.WindowStaysOnTopHint)
     self.setModal(False)
     self.btnHeight = 0
     self.answered = False
     self.move = None
     self.sorry = None
Ejemplo n.º 28
0
class BaseTagDialogFrame(QFrame):
    def __init__(self, parent, name='BaseEntityDataFrame'):
        QFrame.__init__(self, parent, name)
        self.entityid = None
        numrows = 5
        numcols = 1
        margin = 0
        space = 1
        self.grid = QGridLayout(self, numrows, numcols,
                                margin, space, 'BaseEntityDataLayout')
        self.app = get_application_pointer()

        self.lbl = QLabel('Select the tags', self)
        self.grid.addWidget(self.lbl, 0, 0)

        self.listView = KListView(self)
        self.listView.addColumn('tagname', -1)
        self.listView.clear()
        self.grid.addMultiCellWidget(self.listView, 1, 4, 0, 0)
Ejemplo n.º 29
0
class BaseGuestAppearanceFrame(QFrame):
    def __init__(self, parent, name='BaseGuestAppearanceFrame'):
        QFrame.__init__(self, parent, name)
        margin = 0
        space = 1
        self.grid = QGridLayout(self, 4, 1, margin, space)
        self.appearance_lbl = QLabel('Appearance', self)
        self.appearance_url = KLineEdit('', self)
        row = 0
        for widget in [self.appearance_lbl, self.appearance_url]:
            self.grid.addWidget(widget, row, 0)
            row += 1

    def get_data(self):
        url = str(self.appearance_url.text())
        return dict(url=url)

    def set_data(self, data):
        self.appearance_url.setText(data['url'])
class ImportGameDialog(BaseDialogWindow):
    def __init__(self, parent, name='ImportGameDialog'):
        BaseDialogWindow.__init__(self, parent, name=name)
        self.frame = QFrame(self)
        margin = 5
        space = 7
        self.grid = QGridLayout(self.frame, 2, 1, margin, space)
        self.url_lbl = QLabel('URL', self.frame)
        self.url_entry = KLineEdit('', self.frame)
        self.grid.addWidget(self.url_lbl, 0, 0)
        self.grid.addWidget(self.url_entry, 1, 0)
        self.setMainWidget(self.frame)
        self.connect(self, SIGNAL('okClicked()'), self.import_game)
        

    def import_game(self):
        url = str(self.url_entry.text())
        print url
        KMessageBox.information(self, "import_game is still not implemented")
Ejemplo n.º 31
0
class ImportGameUrlDialog(BaseDialogWindow):
    def __init__(self, parent, name='ImportGameUrlDialog'):
        BaseDialogWindow.__init__(self, parent, name=name)
        self.frame = QFrame(self)
        margin = 5
        space = 7
        self.grid = QGridLayout(self.frame, 2, 1, margin, space)
        self.url_lbl = QLabel('URL', self.frame)
        self.url_entry = KLineEdit('', self.frame)
        self.grid.addWidget(self.url_lbl, 0, 0)
        self.grid.addWidget(self.url_entry, 1, 0)
        self.setMainWidget(self.frame)
        self.connect(self, SIGNAL('okClicked()'), self.import_game)
        self.handler = AbandonGamesHandler(self.app)

    def _makeinfo(self, base, parser):
        text = 'Title: %s\n' % parser.title
        if parser.smallinfo:
            text += 'Small Information'
            for k,v in parser.smallinfo.items():
                text += '%s: %s\n' % ( k.capitalize(), v)
        #text += str(parser.smallinfo) + '\n'
        dlurl = base + parser.download_link
        text += 'download page: %s\n' % dlurl
        text += 'direct link: %s\n' % parser.real_download_link
        if parser.files:
            text += 'Files:\n'
            text += '======\n'
            for f in parser.files:
                text += '%s%s\n' % (base, f)
        return text
        
    def import_game(self):
        url = str(self.url_entry.text())
        print url
        #KMessageBox.information(self, "import_game is still not implemented")
        
        #self.handler.get_game_data(url)
        self.handler.handle_url(url)
        #self.handler.parser.feed(file('dunetest.html').read())
        win = AbandoniaInfoWindow(self)
        win.show()
Ejemplo n.º 32
0
class SelectRuleset(QDialog):

    """a dialog for selecting a ruleset"""

    def __init__(self, server=None):
        QDialog.__init__(self, None)
        decorateWindow(self, m18n('Select a ruleset'))
        self.buttonBox = KDialogButtonBox(self)
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.cbRuleset = ListComboBox(Ruleset.selectableRulesets(server))
        self.grid = QGridLayout()  # our child SelectPlayers needs this
        self.grid.setColumnStretch(0, 1)
        self.grid.setColumnStretch(1, 6)
        vbox = QVBoxLayout(self)
        vbox.addLayout(self.grid)
        vbox.addWidget(self.cbRuleset)
        vbox.addWidget(self.buttonBox)
Ejemplo n.º 33
0
class BaseConfigOptionWidget(BaseConfigWidget):
    def __init__(self, parent, labeltext, optclass,
                 name='BaseConfigOptionWidget'):
        BaseConfigWidget.__init__(self, parent, name=name)
        numrows = 2
        numcols = 2
        margin = 0
        space = 1
        self.grid = QGridLayout(self, numrows, numcols,
                                margin, space, 'BaseConfigOptionWidgetLayout')
        self.label = QLabel(labeltext, self)
        self.grid.addWidget(self.label, 0, 0)
        self.mainwidget = optclass(self)
        self.grid.addWidget(self.mainwidget, 1, 0)

    def get_config_option(self):
        raise NotImplementedError, 'get_config_option needs to be defined in subclass'

    def set_config_option(self, option):
        raise NotImplementedError, 'set_config_option needs to be defined in subclass'
Ejemplo n.º 34
0
 def __init__(self, parent, name='BaseGuestAppearanceFrame'):
     QFrame.__init__(self, parent, name)
     margin = 0
     space = 1
     self.grid = QGridLayout(self, 4, 1, margin, space)
     self.appearance_lbl = QLabel('Appearance', self)
     self.appearance_url = KLineEdit('', self)
     row = 0
     for widget in [self.appearance_lbl, self.appearance_url]:
         self.grid.addWidget(widget, row, 0)
         row += 1
Ejemplo n.º 35
0
class BaseGuestPictureFrame(QFrame):
    def __init__(self, parent, name='BaseGuestPictureFrame'):
        QFrame.__init__(self, parent, name)
        margin = 0
        space = 1
        self.grid = QGridLayout(self, 2, 2, margin, space)
        self.picture_lbl = QLabel('Picture', self)
        self.picture_url = KLineEdit('', self)
        self.picture_btn = KPushButton(KStdGuiItem.Open(),
                                       'Browse for picture', self)

        self.grid.addMultiCellWidget(self.picture_lbl, 0, 0, 0, 1)
        self.grid.addWidget(self.picture_url, 0, 1)
        self.grid.addWidget(self.picture_btn, 1, 1)
        
    def get_data(self):
        url = str(self.appearance_url.text())
        return dict(url=url)

    def set_data(self, data):
        self.appearance_url.setText(data['url'])
 def __init__(self, parent, name='ImportGameDialog'):
     BaseDialogWindow.__init__(self, parent, name=name)
     self.frame = QFrame(self)
     margin = 5
     space = 7
     self.grid = QGridLayout(self.frame, 2, 1, margin, space)
     self.url_lbl = QLabel('URL', self.frame)
     self.url_entry = KLineEdit('', self.frame)
     self.grid.addWidget(self.url_lbl, 0, 0)
     self.grid.addWidget(self.url_entry, 1, 0)
     self.setMainWidget(self.frame)
     self.connect(self, SIGNAL('okClicked()'), self.import_game)
Ejemplo n.º 37
0
 def __init__(self, parent, fields, text=None, name='EditableRecordFrame'):
     QFrame.__init__(self, parent, name)
     numrows = len(fields) +2
     numcols = 2
     self.grid = QGridLayout(self, numrows, numcols, 1, -1, name)
     self.fields = fields
     self.entries = {}
     self._setupfields()
     self.grid.setSpacing(7)
     self.grid.setMargin(10)
     self.text_label = QLabel(text, self)
     self.grid.addMultiCellWidget(self.text_label, 0, 0, 0, 1)
Ejemplo n.º 38
0
 def __init__(self, parent, name="SoundBlasterHardwareOptions"):
     QWidget.__init__(self, parent, name)
     numrows = 2
     numcols = 1
     margin = 0
     space = 1
     self.grid = QGridLayout(self, numrows, numcols, margin, space, "SoundBlasterHardwareOptionsLayout")
     self._default_oplmodes = ["auto", "cms", "opl2", "dualopl2", "opl3"]
     self.oplmode_box = ConfigComboBoxWidget(self, "OPL mode", self._default_oplmodes)
     self.grid.addWidget(self.oplmode_box, 0, 0)
     self.oplrate_box = SampleRateOption(self, "OPL sample rate")
     self.grid.addWidget(self.oplrate_box, 1, 0)
Ejemplo n.º 39
0
 def onDockChartViewToggled(self, checked):
   if checked:
     self.chartPopupWindow = QDialog()
     self.chartPopupWindow.setWindowFlags(PythonQt.QtCore.Qt.WindowStaysOnTopHint)
     layout = QGridLayout()
     self.chartPopupWindow.setLayout(layout)
     layout.addWidget(self._multiVolumeIntensityChart.chartView)
     layout.addWidget(self.popupChartButton)
     self.chartPopupWindow.finished.connect(self.dockChartView)
     self.chartPopupWindow.resize(self.chartPopupSize)
     self.chartPopupWindow.move(self.chartPopupPosition)
     self.chartPopupWindow.show()
     self.popupChartButton.setText("Dock chart")
     self._multiVolumeIntensityChart.chartView.show()
   else:
     self.chartPopupWindow.close()
class qSlicerMultiVolumeExplorerSimplifiedModuleWidget:
    def __init__(self, parent=None):
        logging.debug(
            "qSlicerMultiVolumeExplorerSimplifiedModuleWidget:init() called")
        if not parent or not hasattr(parent, "layout"):
            self.parent = slicer.qMRMLWidget()
            self.parent.setLayout(QVBoxLayout())
        else:
            self.parent = parent

        self.layout = self.parent.layout()

        self._bgMultiVolumeNode = None
        self._fgMultiVolumeNode = None

        self.styleObserverTags = []
        self.sliceWidgetsPerStyle = {}

        self.chartPopupWindow = None
        self.chartPopupSize = QSize(600, 300)
        self.chartPopupPosition = QPoint(0, 0)

    def hide(self):
        self.widget.hide()

    def show(self):
        self.widget.show()

    def setup(self):
        self.widget = QWidget()
        layout = QGridLayout()
        self.widget.setLayout(layout)
        self.layout.addWidget(self.widget)
        self.widget.show()
        self.layout = layout

        self.setupInputFrame()
        self.setupFrameControlFrame()
        self.setupAdditionalFrames()
        self.setupPlottingFrame()

        self.setFramesEnabled(False)

        self.timer = QTimer()
        self.timer.setInterval(50)

        self.setupConnections()

        # initialize slice observers (from DataProbe.py)
        # keep list of pairs: [observee,tag] so they can be removed easily
        self.styleObserverTags = []
        # keep a map of interactor styles to sliceWidgets so we can easily get sliceLogic
        self.sliceWidgetsPerStyle = {}
        self.refreshObservers()

    def setupInputFrame(self, parent=None):
        if not parent:
            parent = self.layout
        self.bgMultiVolumeSelector = slicer.qMRMLNodeComboBox()
        self.bgMultiVolumeSelector.nodeTypes = ['vtkMRMLMultiVolumeNode']
        self.bgMultiVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.bgMultiVolumeSelector.addEnabled = 0
        self._bgMultiVolumeSelectorLabel = QLabel('Input multivolume')
        inputFrameWidget = QWidget()
        self.inputFrameLayout = QFormLayout()
        inputFrameWidget.setLayout(self.inputFrameLayout)
        self.inputFrameLayout.addRow(self._bgMultiVolumeSelectorLabel,
                                     self.bgMultiVolumeSelector)
        parent.addWidget(inputFrameWidget)

    def setupFrameControlFrame(self):
        # TODO: initialize the slider based on the contents of the labels array
        self.frameSlider = ctk.ctkSliderWidget()
        self.frameSlider.setSizePolicy(QSizePolicy.Ignored,
                                       QSizePolicy.Preferred)
        self.frameLabel = QLabel('Current frame number')
        self.playButton = QPushButton('Play')
        self.playButton.toolTip = 'Iterate over multivolume frames'
        self.playButton.checkable = True
        frameControlHBox = QHBoxLayout()
        frameControlHBox.addWidget(self.frameLabel)
        frameControlHBox.addWidget(self.frameSlider)
        frameControlHBox.addWidget(self.playButton)
        self.inputFrameLayout.addRow(frameControlHBox)

    def setupAdditionalFrames(self):
        pass

    def setupPlottingFrame(self, parent=None):
        if not parent:
            parent = self.layout
        self.plottingFrameWidget = QWidget()
        self.plottingFrameLayout = QGridLayout()
        self.plottingFrameWidget.setLayout(self.plottingFrameLayout)
        self._multiVolumeIntensityChart = MultiVolumeIntensityChartView()
        self.popupChartButton = QPushButton("Undock chart")
        self.popupChartButton.setCheckable(True)
        self.plottingFrameLayout.addWidget(
            self._multiVolumeIntensityChart.chartView)
        self.plottingFrameLayout.addWidget(self.popupChartButton)
        parent.addWidget(self.plottingFrameWidget)

    def setupConnections(self):
        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.onVCMRMLSceneChanged)
        self.bgMultiVolumeSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                           self.onBackgroundInputChanged)
        self.playButton.connect('toggled(bool)', self.onPlayButtonToggled)
        self.frameSlider.connect('valueChanged(double)', self.onSliderChanged)
        self.timer.connect('timeout()', self.goToNext)
        self.popupChartButton.connect('toggled(bool)',
                                      self.onDockChartViewToggled)

    def onDockChartViewToggled(self, checked):
        if checked:
            self.chartPopupWindow = QDialog()
            self.chartPopupWindow.setWindowFlags(
                PythonQt.QtCore.Qt.WindowStaysOnTopHint)
            layout = QGridLayout()
            self.chartPopupWindow.setLayout(layout)
            layout.addWidget(self._multiVolumeIntensityChart.chartView)
            layout.addWidget(self.popupChartButton)
            self.chartPopupWindow.finished.connect(self.dockChartView)
            self.chartPopupWindow.resize(self.chartPopupSize)
            self.chartPopupWindow.move(self.chartPopupPosition)
            self.chartPopupWindow.show()
            self.popupChartButton.setText("Dock chart")
            self._multiVolumeIntensityChart.chartView.show()
        else:
            self.chartPopupWindow.close()

    def dockChartView(self):
        self.chartPopupSize = self.chartPopupWindow.size
        self.chartPopupPosition = self.chartPopupWindow.pos
        self.plottingFrameLayout.addWidget(
            self._multiVolumeIntensityChart.chartView)
        self.plottingFrameLayout.addWidget(self.popupChartButton)
        self.popupChartButton.setText("Undock chart")
        self.popupChartButton.disconnect('toggled(bool)',
                                         self.onDockChartViewToggled)
        self.popupChartButton.checked = False
        self.popupChartButton.connect('toggled(bool)',
                                      self.onDockChartViewToggled)

    def onSliderChanged(self, frameId):
        if self._bgMultiVolumeNode is None:
            return
        newValue = int(frameId)
        self.setCurrentFrameNumber(newValue)

    def onVCMRMLSceneChanged(self, mrmlScene):
        logging.debug(
            "qSlicerMultiVolumeExplorerSimplifiedModuleWidget:onVCMRMLSceneChanged"
        )
        self.bgMultiVolumeSelector.setMRMLScene(slicer.mrmlScene)
        self.onBackgroundInputChanged()

    def refreshGUIForNewBackgroundImage(self):
        self._multiVolumeIntensityChart.reset()
        self.setFramesEnabled(True)
        if self._fgMultiVolumeNode and self._bgMultiVolumeNode:
            Helper.SetBgFgVolumes(self._bgMultiVolumeNode.GetID(),
                                  self._fgMultiVolumeNode.GetID())
        else:
            Helper.SetBgVolume(self._bgMultiVolumeNode.GetID())
        self.refreshFrameSlider()
        self._multiVolumeIntensityChart.bgMultiVolumeNode = self._bgMultiVolumeNode
        self.refreshObservers()

    def getBackgroundMultiVolumeNode(self):
        return self.bgMultiVolumeSelector.currentNode()

    def onBackgroundInputChanged(self):
        self._bgMultiVolumeNode = self.getBackgroundMultiVolumeNode()

        if self._bgMultiVolumeNode is not None:
            self.refreshGUIForNewBackgroundImage()
        else:
            self.setFramesEnabled(False)

    def onPlayButtonToggled(self, checked):
        if self._bgMultiVolumeNode is None:
            return
        if checked:
            self.timer.start()
            self.playButton.text = 'Stop'
        else:
            self.timer.stop()
            self.playButton.text = 'Play'

    def processEvent(self, observee, event):
        # logging.debug("processing event %s" % event)
        if self._bgMultiVolumeNode is None:
            return

        # TODO: use a timer to delay calculation and compress events
        if event == 'LeaveEvent':
            # reset all the readouts
            # TODO: reset the label text
            return

        if not self.sliceWidgetsPerStyle.has_key(observee):
            return

        interactor = observee.GetInteractor()
        self.createChart(self.sliceWidgetsPerStyle[observee],
                         interactor.GetEventPosition())

    def createChart(self, sliceWidget, position):
        self._multiVolumeIntensityChart.createChart(sliceWidget, position)

    def setCurrentFrameNumber(self, frameNumber):
        mvDisplayNode = self._bgMultiVolumeNode.GetDisplayNode()
        mvDisplayNode.SetFrameComponent(frameNumber)

    def setFramesEnabled(self, enabled):
        pass

    def refreshObservers(self):
        """ When the layout changes, drop the observers from
    all the old widgets and create new observers for the
    newly created widgets"""
        self.removeObservers()
        # get new slice nodes
        layoutManager = slicer.app.layoutManager()
        sliceNodeCount = slicer.mrmlScene.GetNumberOfNodesByClass(
            'vtkMRMLSliceNode')
        for nodeIndex in xrange(sliceNodeCount):
            # find the widget for each node in scene
            sliceNode = slicer.mrmlScene.GetNthNodeByClass(
                nodeIndex, 'vtkMRMLSliceNode')
            sliceWidget = layoutManager.sliceWidget(sliceNode.GetLayoutName())
            if sliceWidget:
                # add observers and keep track of tags
                style = sliceWidget.sliceView().interactorStyle()
                self.sliceWidgetsPerStyle[style] = sliceWidget
                events = ("MouseMoveEvent", "EnterEvent", "LeaveEvent")
                for event in events:
                    tag = style.AddObserver(event, self.processEvent)
                    self.styleObserverTags.append([style, tag])

    def removeObservers(self):
        for observee, tag in self.styleObserverTags:
            observee.RemoveObserver(tag)
        self.styleObserverTags = []
        self.sliceWidgetsPerStyle = {}

    def refreshFrameSlider(self):
        self.frameSlider.minimum = 0
        if not self._bgMultiVolumeNode:
            self.frameSlider.maximum = 0
            return
        nFrames = self._bgMultiVolumeNode.GetNumberOfFrames()
        self.frameSlider.maximum = nFrames - 1

    def goToNext(self):
        currentElement = self.frameSlider.value
        currentElement += 1
        if currentElement > self.frameSlider.maximum:
            currentElement = 0
        self.frameSlider.value = currentElement
Ejemplo n.º 41
0
    def __init__(self, repositoryManager):
        """ Constructor. """

        # Init GUI
        AdminWindow.__init__(self)

        # set icon in window-title:
        self.setIcon(QPixmap.fromMimeSource("DF_Logo_24x24.png"))
        iconSet = QIconSet(QPixmap.fromMimeSource("dataType16.png"))
        self.dataNavigator.setTabIconSet(self.dataTypes, iconSet)
        iconSet = QIconSet(QPixmap.fromMimeSource("relationType16.png"))
        self.dataNavigator.setTabIconSet(self.relationTypes, iconSet)
        iconSet = QIconSet(QPixmap.fromMimeSource("dataStore16.png"))
        self.dataNavigator.setTabIconSet(self.dataStores, iconSet)

        logger_handler.installGuiLoggingHandler(self.__logger, self.logList)

        self.myStatusBar = self.statusBar()
        self.statusLabel1 = QLabel("DataFinder", self.myStatusBar)
        self.statusLabel2 = QLabel("OK", self.myStatusBar)

        self.myStatusBar.addWidget(self.statusLabel1, 80)
        self.myStatusBar.addWidget(self.statusLabel2, 20)

        self.statusLabel1.show()
        self.statusLabel2.show()
        self.myStatusBar.show()

        # prepare "About"-dialog:
        self.dfAboutDialog = about_dialog.AboutDialog()
        self.dfAboutDialog.setPixmap(
            QPixmap.fromMimeSource("about_datafinder_admin.png"))

        # Login-dialog:
        self.dfLoginDialog = login_dialog.LoginDialog(
            repositoryManager.preferences, parent=self, showurl=True)

        # IconView:
        propertyPanelLayout = QGridLayout(self.propertyPanel, 1, 1, 2, 6,
                                          "propertyPanelLayout")

        self.iconView = canvas_view.CanvasView(self.propertyPanel, self,
                                               "iconView", 0)
        propertyPanelLayout.addWidget(self.iconView, 0, 0)

        self.iconViewCanvas = self.iconView.canvas()

        self.connect(self.dfLoginDialog.okPushButton,
                     PYSIGNAL("updateWebdavServerView"),
                     self.updateWebdavServerSlot)
        self.connect(self.dataTypeBrowser,
                     SIGNAL("doubleClicked(QListViewItem*)"),
                     self.__addDataTypeIconSlot)
        self.connect(self.relationTypeBrowser,
                     SIGNAL("doubleClicked(QListViewItem*)"),
                     self.__addRelationTypeIconSlot)
        self.connect(self.dataStoreBrowser, SIGNAL("clicked(QListViewItem*)"),
                     self.iconView.updateCanvasView)
        self.connect(self.dataStoreBrowser,
                     SIGNAL("doubleClicked(QListViewItem*)"), self.editSlot)

        # Init model
        self._repositoryManager = repositoryManager
        self.repositoryConfiguration = None
        self._preferences = self._repositoryManager.preferences
        self._lastUploadDirectory = os.path.expanduser("~")

        self._dataTypes = list()
        self._relationTypes = list()
        self._dataStores = list()

        self.__setConnectionState(False)
Ejemplo n.º 42
0
 def __init__(self, game):
     """selection for this player, tiles are the still available tiles"""
     QDialog.__init__(self, None)
     decorateWindow(self, i18n("Penalty"))
     self.game = game
     grid = QGridLayout(self)
     lblOffense = QLabel(i18n('Offense:'))
     crimes = list([
         x for x in game.ruleset.penaltyRules
         if not ('absolute' in x.options and game.winner)
     ])
     self.cbCrime = ListComboBox(crimes)
     lblOffense.setBuddy(self.cbCrime)
     grid.addWidget(lblOffense, 0, 0)
     grid.addWidget(self.cbCrime, 0, 1, 1, 4)
     lblPenalty = QLabel(i18n('Total Penalty'))
     self.spPenalty = PenaltyBox(2)
     self.spPenalty.setRange(0, 9999)
     lblPenalty.setBuddy(self.spPenalty)
     self.lblUnits = QLabel(i18n('points'))
     grid.addWidget(lblPenalty, 1, 0)
     grid.addWidget(self.spPenalty, 1, 1)
     grid.addWidget(self.lblUnits, 1, 2)
     self.payers = []
     self.payees = []
     # a penalty can never involve the winner, neither as payer nor as payee
     for idx in range(3):
         self.payers.append(ListComboBox(game.losers()))
         self.payees.append(ListComboBox(game.losers()))
     for idx, payer in enumerate(self.payers):
         grid.addWidget(payer, 3 + idx, 0)
         payer.lblPayment = QLabel()
         grid.addWidget(payer.lblPayment, 3 + idx, 1)
     for idx, payee in enumerate(self.payees):
         grid.addWidget(payee, 3 + idx, 3)
         payee.lblPayment = QLabel()
         grid.addWidget(payee.lblPayment, 3 + idx, 4)
     grid.addWidget(QLabel(''), 6, 0)
     grid.setRowStretch(6, 10)
     for player in self.payers + self.payees:
         player.currentIndexChanged.connect(self.playerChanged)
     self.spPenalty.valueChanged.connect(self.penaltyChanged)
     self.cbCrime.currentIndexChanged.connect(self.crimeChanged)
     buttonBox = KDialogButtonBox(self)
     grid.addWidget(buttonBox, 7, 0, 1, 5)
     buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
     buttonBox.rejected.connect(self.reject)
     self.btnExecute = buttonBox.addButton(i18n("&Execute"),
                                           QDialogButtonBox.AcceptRole)
     self.btnExecute.clicked.connect(self.accept)
     self.crimeChanged()
     StateSaver(self)
Ejemplo n.º 43
0
 def __init__(self, scene):
     QWidget.__init__(self)
     self.scene = scene
     decorateWindow(self, i18n('Scoring for this Hand'))
     self.nameLabels = [None] * 4
     self.spValues = [None] * 4
     self.windLabels = [None] * 4
     self.wonBoxes = [None] * 4
     self.detailsLayout = [None] * 4
     self.details = [None] * 4
     self.__tilePixMaps = []
     self.__meldPixMaps = []
     grid = QGridLayout(self)
     pGrid = QGridLayout()
     grid.addLayout(pGrid, 0, 0, 2, 1)
     pGrid.addWidget(QLabel(i18nc('kajongg', "Player")), 0, 0)
     pGrid.addWidget(QLabel(i18nc('kajongg', "Wind")), 0, 1)
     pGrid.addWidget(QLabel(i18nc('kajongg', 'Score')), 0, 2)
     pGrid.addWidget(QLabel(i18n("Winner")), 0, 3)
     self.detailTabs = QTabWidget()
     self.detailTabs.setDocumentMode(True)
     pGrid.addWidget(self.detailTabs, 0, 4, 8, 1)
     for idx in range(4):
         self.setupUiForPlayer(pGrid, idx)
     self.draw = QCheckBox(i18nc('kajongg', 'Draw'))
     self.draw.clicked.connect(self.wonChanged)
     btnPenalties = QPushButton(i18n("&Penalties"))
     btnPenalties.clicked.connect(self.penalty)
     self.btnSave = QPushButton(i18n('&Save Hand'))
     self.btnSave.clicked.connect(self.game.nextScoringHand)
     self.btnSave.setEnabled(False)
     self.setupUILastTileMeld(pGrid)
     pGrid.setRowStretch(87, 10)
     pGrid.addWidget(self.draw, 7, 3)
     self.cbLastTile.currentIndexChanged.connect(self.slotLastTile)
     self.cbLastMeld.currentIndexChanged.connect(self.slotInputChanged)
     btnBox = QHBoxLayout()
     btnBox.addWidget(btnPenalties)
     btnBox.addWidget(self.btnSave)
     pGrid.addLayout(btnBox, 8, 4)
     StateSaver(self)
     self.refresh()
Ejemplo n.º 44
0
class ClientDialog(QDialog):

    """a simple popup dialog for asking the player what he wants to do"""

    def __init__(self, client, parent=None):
        QDialog.__init__(self, parent)
        decorateWindow(self, i18n('Choose'))
        self.setObjectName('ClientDialog')
        self.client = client
        self.layout = QGridLayout(self)
        self.progressBar = QProgressBar()
        self.progressBar.setMinimumHeight(25)
        self.timer = QTimer()
        if not client.game.autoPlay:
            self.timer.timeout.connect(self.timeout)
        self.deferred = None
        self.buttons = []
        self.setWindowFlags(Qt.SubWindow | Qt.WindowStaysOnTopHint)
        self.setModal(False)
        self.btnHeight = 0
        self.answered = False
        self.move = None
        self.sorry = None

    def keyPressEvent(self, event):
        """ESC selects default answer"""
        if not self.client.game or self.client.game.autoPlay:
            return
        if event.key() in [Qt.Key_Escape, Qt.Key_Space]:
            self.selectButton()
            event.accept()
        else:
            for btn in self.buttons:
                if str(event.text()).upper() == btn.message.shortcut:
                    self.selectButton(btn)
                    event.accept()
                    return
            QDialog.keyPressEvent(self, event)

    def __declareButton(self, message):
        """define a button"""
        maySay = self.client.game.myself.sayable[message]
        if Internal.Preferences.showOnlyPossibleActions and not maySay:
            return
        btn = DlgButton(message, self)
        btn.setAutoDefault(True)
        btn.clicked.connect(self.selectedAnswer)
        self.buttons.append(btn)

    def focusTileChanged(self):
        """update icon and tooltip for the discard button"""
        if not self.client.game:
            return
        for button in self.buttons:
            button.setMeaning(self.client.game.myself.handBoard.focusTile)
        for uiTile in self.client.game.myself.handBoard.lowerHalfTiles():
            txt = []
            for button in self.buttons:
                _, _, tileTxt = button.message.toolTip(button, uiTile.tile)
                if tileTxt:
                    txt.append(tileTxt)
            uiTile.setToolTip('<br><br>'.join(txt))
        if self.client.game.activePlayer == self.client.game.myself:
            Internal.scene.handSelectorChanged(
                self.client.game.myself.handBoard)

    def checkTiles(self):
        """does the logical state match the displayed tiles?"""
        for player in self.client.game.players:
            player.handBoard.checkTiles()

    def messages(self):
        """a list of all messages returned by the declared buttons"""
        return list(x.message for x in self.buttons)

    def proposeAction(self):
        """either intelligently or first button by default. May also
        focus a proposed tile depending on the action."""
        result = self.buttons[0]
        game = self.client.game
        if game.autoPlay or Internal.Preferences.propose:
            answer, parameter = game.myself.intelligence.selectAnswer(
                self.messages())
            result = [x for x in self.buttons if x.message == answer][0]
            result.setFocus()
            if answer in [Message.Discard, Message.OriginalCall]:
                for uiTile in game.myself.handBoard.uiTiles:
                    if uiTile.tile is parameter:
                        game.myself.handBoard.focusTile = uiTile
        return result

    def askHuman(self, move, answers, deferred):
        """make buttons specified by answers visible. The first answer is default.
        The default button only appears with blue border when this dialog has
        focus but we always want it to be recognizable. Hence setBackgroundRole."""
        self.move = move
        self.deferred = deferred
        for answer in answers:
            self.__declareButton(answer)
        self.focusTileChanged()
        self.show()
        self.checkTiles()
        game = self.client.game
        myTurn = game.activePlayer == game.myself
        prefButton = self.proposeAction()
        if game.autoPlay:
            self.selectButton(prefButton)
            return
        prefButton.setFocus()

        self.progressBar.setVisible(not myTurn)
        if not myTurn:
            msecs = 50
            self.progressBar.setMinimum(0)
            self.progressBar.setMaximum(
                game.ruleset.claimTimeout * 1000 // msecs)
            self.progressBar.reset()
            self.timer.start(msecs)

    def placeInField(self):
        """place the dialog at bottom or to the right depending on space."""
        mainWindow = Internal.scene.mainWindow
        cwi = mainWindow.centralWidget()
        view = mainWindow.centralView
        geometry = self.geometry()
        if not self.btnHeight:
            self.btnHeight = self.buttons[0].height()
        vertical = view.width() > view.height() * 1.2
        if vertical:
            height = (len(self.buttons) + 1) * self.btnHeight * 1.2
            width = (cwi.width() - cwi.height()) // 2
            geometry.setX(cwi.width() - width)
            geometry.setY(min(cwi.height() // 3, cwi.height() - height))
        else:
            handBoard = self.client.game.myself.handBoard
            if not handBoard:
                # we are in the progress of logging out
                return
            hbLeftTop = view.mapFromScene(
                handBoard.mapToScene(handBoard.rect().topLeft()))
            hbRightBottom = view.mapFromScene(
                handBoard.mapToScene(handBoard.rect().bottomRight()))
            width = hbRightBottom.x() - hbLeftTop.x()
            height = self.btnHeight
            geometry.setY(cwi.height() - height)
            geometry.setX(hbLeftTop.x())
        for idx, btn in enumerate(self.buttons + [self.progressBar]):
            self.layout.addWidget(
                btn,
                idx +
                1 if vertical else 0,
                idx +
                1 if not vertical else 0)
        idx = len(self.buttons) + 2
        spacer = QSpacerItem(
            20,
            20,
            QSizePolicy.Expanding,
            QSizePolicy.Expanding)
        self.layout.addItem(
            spacer,
            idx if vertical else 0,
            idx if not vertical else 0)

        geometry.setWidth(width)
        geometry.setHeight(height)
        self.setGeometry(geometry)

    def showEvent(self, dummyEvent):
        """try to place the dialog such that it does not cover interesting information"""
        self.placeInField()

    def timeout(self):
        """the progressboard wants an update"""
        pBar = self.progressBar
        if isAlive(pBar):
            pBar.setValue(pBar.value() + 1)
            pBar.setVisible(True)
            if pBar.value() == pBar.maximum():
                # timeout: we always return the original default answer, not
                # the one with focus
                self.selectButton()
                pBar.setVisible(False)

    def selectButton(self, button=None):
        """select default answer. button may also be of type Message."""
        if self.answered:
            # sometimes we get this event twice
            return
        if button is None:
            button = self.focusWidget()
        if isinstance(button, Message):
            assert any(x.message == button for x in self.buttons)
            answer = button
        else:
            answer = button.message
        if not self.client.game.myself.sayable[answer]:
            self.proposeAction().setFocus() # go back to default action
            self.sorry = Sorry(i18n('You cannot say %1', answer.i18nName))
            return
        self.timer.stop()
        self.answered = True
        if self.sorry:
            self.sorry.cancel()
        self.sorry = None
        Internal.scene.clientDialog = None
        self.deferred.callback(answer)

    def selectedAnswer(self, dummyChecked):
        """the user clicked one of the buttons"""
        game = self.client.game
        if game and not game.autoPlay:
            self.selectButton(self.sender())
Ejemplo n.º 45
0
class EditableRecordFrame(QFrame):
    def __init__(self, parent, fields, text=None, name='EditableRecordFrame'):
        QFrame.__init__(self, parent, name)
        numrows = len(fields) + 2
        numcols = 2
        self.grid = QGridLayout(self, numrows, numcols, 1, -1, name)
        self.fields = fields
        self.entries = {}
        self._setupfields()
        self.grid.setSpacing(7)
        self.grid.setMargin(10)
        self.text_label = QLabel(text, self)
        self.grid.addMultiCellWidget(self.text_label, 0, 0, 0, 1)

    def _setupfields(self):
        numfields = len(self.fields)
        for fnum in range(numfields):
            fname = self.fields[fnum]
            entry = KLineEdit('', self)
            self.entries[fname] = entry
            self.grid.addWidget(entry, fnum + 1, 1)
            label = QLabel(entry, fname, self, fname)
            self.grid.addWidget(label, fnum + 1, 0)
        self.insButton = KPushButton('insert/new', self)
        self.updButton = KPushButton('update', self)
        self.grid.addWidget(self.insButton, numfields, 0)
        self.grid.addWidget(self.updButton, numfields, 1)

    def get_data(self):
        data = {}
        for field in self.entries:
            data[field] = str(self.entries[field].text())
        return data
Ejemplo n.º 46
0
 def setupUi(self):
     """create all other widgets
     we could make the scene view the central widget but I did
     not figure out how to correctly draw the background with
     QGraphicsView/QGraphicsScene.
     QGraphicsView.drawBackground always wants a pixmap
     for a huge rect like 4000x3000 where my screen only has
     1920x1200"""
     # pylint: disable=too-many-statements
     self.setObjectName("MainWindow")
     centralWidget = QWidget()
     self.centralView = FittingView()
     layout = QGridLayout(centralWidget)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget(self.centralView)
     self.setCentralWidget(centralWidget)
     self.centralView.setFocusPolicy(Qt.StrongFocus)
     self.background = None  # just for pylint
     self.windTileset = Tileset(Internal.Preferences.windTilesetName)
     self.adjustMainView()
     self.actionScoreGame = self.kajonggAction("scoreGame", "draw-freehand",
                                               self.scoringScene, Qt.Key_C)
     self.actionPlayGame = self.kajonggAction("play", "arrow-right",
                                              self.playGame, Qt.Key_N)
     self.actionAbortGame = self.kajonggAction("abort", "dialog-close",
                                               self.abortAction, Qt.Key_W)
     self.actionAbortGame.setEnabled(False)
     self.actionQuit = self.kajonggAction("quit", "application-exit",
                                          self.close, Qt.Key_Q)
     self.actionPlayers = self.kajonggAction("players", "im-user",
                                             self.slotPlayers)
     self.actionRulesets = self.kajonggAction("rulesets",
                                              "games-kajongg-law",
                                              self.slotRulesets)
     self.actionChat = self._kajonggToggleAction("chat",
                                                 "call-start",
                                                 shortcut=Qt.Key_H,
                                                 actionData=ChatWindow)
     self.actionChat.setEnabled(False)
     self.actionAngle = self.kajonggAction("angle", "object-rotate-left",
                                           self.changeAngle, Qt.Key_G)
     self.actionAngle.setEnabled(False)
     self.actionScoreTable = self._kajonggToggleAction(
         "scoreTable",
         "format-list-ordered",
         Qt.Key_T,
         actionData=ScoreTable)
     self.actionScoreTable.setEnabled(False)
     self.actionExplain = self._kajonggToggleAction(
         "explain",
         "applications-education",
         Qt.Key_E,
         actionData=ExplainView)
     self.actionExplain.setEnabled(False)
     self.actionFullscreen = self._kajonggToggleAction("fullscreen",
                                                       "view-fullscreen",
                                                       shortcut=Qt.Key_F +
                                                       Qt.ShiftModifier)
     self.actionFullscreen.toggled.connect(self.fullScreen)
     self.actionAutoPlay = self.kajonggAction("demoMode",
                                              "arrow-right-double", None,
                                              Qt.Key_D)
     self.actionAutoPlay.setCheckable(True)
     self.actionAutoPlay.setEnabled(True)
     self.actionAutoPlay.toggled.connect(self._toggleDemoMode)
     self.actionAutoPlay.setChecked(Internal.autoPlay)
     QMetaObject.connectSlotsByName(self)
    def setupPanel(self, parentWidget):
        logging.debug('ProstateTRUSNavUltrasound.setupPanel')

        self.connectorNode = self.guideletParent.connectorNode
        self.connectorNodeConnected = False

        collapsibleButton = ctkCollapsibleButton()
        collapsibleButton.setProperty('collapsedHeight', 20)
        setButtonStyle(collapsibleButton, 2.0)
        collapsibleButton.text = "Ultrasound"
        parentWidget.addWidget(collapsibleButton)

        ultrasoundLayout = QFormLayout(collapsibleButton)
        ultrasoundLayout.setContentsMargins(12, 4, 4, 4)
        ultrasoundLayout.setSpacing(4)

        self.connectDisconnectButton = QPushButton("Connect")
        self.connectDisconnectButton.setToolTip(
            "If clicked, connection OpenIGTLink")

        hbox = QHBoxLayout()
        hbox.addWidget(self.connectDisconnectButton)
        ultrasoundLayout.addRow(hbox)

        self.setupIcons()

        self.captureIDSelector = QComboBox()
        self.captureIDSelector.setToolTip("Pick capture device ID")
        self.captureIDSelector.setSizePolicy(QSizePolicy.Expanding,
                                             QSizePolicy.Expanding)

        self.volumeReconstructorIDSelector = QComboBox()
        self.volumeReconstructorIDSelector.setToolTip(
            "Pick volume reconstructor device ID")
        self.volumeReconstructorIDSelector.setSizePolicy(
            QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.startStopRecordingButton = QPushButton("  Start Recording")
        self.startStopRecordingButton.setCheckable(True)
        self.startStopRecordingButton.setIcon(self.recordIcon)
        self.startStopRecordingButton.setEnabled(False)
        self.startStopRecordingButton.setToolTip("If clicked, start recording")
        self.startStopRecordingButton.setSizePolicy(QSizePolicy.Expanding,
                                                    QSizePolicy.Expanding)

        recordParametersControlsLayout = QGridLayout()

        self.filenameLabel = self.createLabel("Filename:", visible=False)
        recordParametersControlsLayout.addWidget(self.filenameLabel, 1, 0)

        # Offline Reconstruction
        self.offlineReconstructButton = QPushButton("  Offline Reconstruction")
        self.offlineReconstructButton.setCheckable(True)
        self.offlineReconstructButton.setIcon(self.recordIcon)
        self.offlineReconstructButton.setEnabled(False)
        self.offlineReconstructButton.setToolTip(
            "If clicked, reconstruct recorded volume")
        self.offlineReconstructButton.setSizePolicy(QSizePolicy.Expanding,
                                                    QSizePolicy.Expanding)

        self.offlineVolumeToReconstructSelector = QComboBox()
        self.offlineVolumeToReconstructSelector.setEditable(True)
        self.offlineVolumeToReconstructSelector.setToolTip(
            "Pick/set volume to reconstruct")
        self.offlineVolumeToReconstructSelector.visible = False

        hbox = QHBoxLayout()
        hbox.addWidget(self.startStopRecordingButton)
        hbox.addWidget(self.offlineReconstructButton)
        ultrasoundLayout.addRow(hbox)

        # Scout scan (record and low resolution reconstruction) and live reconstruction
        # Scout scan part

        self.startStopScoutScanButton = QPushButton(
            "  Scout scan\n  Start recording")
        self.startStopScoutScanButton.setCheckable(True)
        self.startStopScoutScanButton.setIcon(self.recordIcon)
        self.startStopScoutScanButton.setToolTip("If clicked, start recording")
        self.startStopScoutScanButton.setEnabled(False)
        self.startStopScoutScanButton.setSizePolicy(QSizePolicy.Expanding,
                                                    QSizePolicy.Expanding)

        self.startStopLiveReconstructionButton = QPushButton(
            "  Start live reconstruction")
        self.startStopLiveReconstructionButton.setCheckable(True)
        self.startStopLiveReconstructionButton.setIcon(self.recordIcon)
        self.startStopLiveReconstructionButton.setToolTip(
            "If clicked, start live reconstruction")
        self.startStopLiveReconstructionButton.setEnabled(False)
        self.startStopLiveReconstructionButton.setSizePolicy(
            QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.displayRoiButton = QToolButton()
        self.displayRoiButton.setCheckable(True)
        self.displayRoiButton.setIcon(self.visibleOffIcon)
        self.displayRoiButton.setToolTip("If clicked, display ROI")

        hbox = QHBoxLayout()
        hbox.addWidget(self.startStopScoutScanButton)
        hbox.addWidget(self.startStopLiveReconstructionButton)
        # hbox.addWidget(self.displayRoiButton)
        ultrasoundLayout.addRow(hbox)

        self.snapshotTimer = QTimer()
        self.snapshotTimer.setSingleShot(True)

        self.onParameterSetSelected()

        return collapsibleButton
Ejemplo n.º 48
0
class InstallerWidget(QWidget):
    def __init__(self, parent, umlmachines, name='InstallerWidget'):
        QWidget.__init__(self, parent, name)
        self.resize(600, 600)
        self.app = get_application_pointer()
        self.conn = self.app.conn
        self.umlmachines = umlmachines
        self.machine = self.umlmachines.current
        self.current_machine_process = 'start'
        self.current_profile = None
        self.current_trait = None
        self.traitlist = []
        self.curenv = CurrentEnvironment(self.conn, self.machine)
        self.curenv['current_profile'] = 'None'
        self.curenv['current_trait'] = 'None'
        self.curenv['current_machine_process'] = self.current_machine_process
        self.timer = QTimer(self)
        self.connect(self.timer, SIGNAL('timeout()'), self.update_progress)
        self.timer.startTimer(1000)
        self.grid = QGridLayout(self, 4, 1, 5, 7)
        self.main_label = QLabel(self)
        self.main_label.setText(self._msg())
        self.grid.addWidget(self.main_label, 0, 0)
        self.profile_progress_lbl = QLabel(self)
        self.grid.addWidget(self.profile_progress_lbl, 1, 0)
        self.profile_progress = KProgress(self)
        self.grid.addWidget(self.profile_progress, 2, 0)
        self.logview = LogBrowser(self, '/tmp/uml-installer.log')
        self.grid.addWidget(self.logview, 3, 0)
        #self.console_view = StdOutBrowser(self)
        #self.console_view = KTextBrowser(self)
        #self.grid.addWidget(self.console_view, 4, 0)
        self.console_text = ''

    def _msg(self):
        return 'Installing uml machine %s - %s' % (
            self.machine, self.current_machine_process)

    def update_console_text(self):
        if self.umlmachines.run_process is not None:
            stdout = self.umlmachines.run_process.stdout
            stdoutfd = stdout.fileno()
            ready = select.select([stdoutfd], [], [])
            while stdoutfd in ready[0]:
                line = stdout.readline()
                if line:
                    self.console_text += line
                ready = select.select([stdoutfd], [], [])
            stdout = self.umlmachines.run_process.stdout
            line = stdout.readline()
            if line:
                self.console_text += line
            self.console_view.setText(self.console_text)

    def update_progress(self):
        #self.update_console_text()
        process = self.curenv['current_machine_process']
        #print 'update_progress', process
        if process != self.current_machine_process:
            self.current_machine_process = process
            self.main_label.setText(self._msg())
        if self.current_profile is None:
            profile = self.curenv['current_profile']
            if profile != 'None':
                self.current_profile = profile
                print 'profile set to', profile
                traitlist = self.curenv['traitlist']
                tl = [t.strip() for t in traitlist.split(',')]
                self.traitlist = tl
                self.profile_progress.setTotalSteps(len(self.traitlist))
        else:
            trait = self.curenv['current_trait']
            if trait != 'None':
                trait_process = self.curenv['current_trait_process']
                profile = self.current_profile
                msg = 'Installing profile %s, trait %s, process %s' % (
                    profile, trait, trait_process)
                self.profile_progress_lbl.setText(msg)
                self.profile_progress.setProgress(
                    self.traitlist.index(trait) + 1)
                self.app.processEvents()