Exemple #1
0
    def getPixmap(self, node):
        """ getPixmap(node) -> returns an appropriate pixmap for a node

        """
        node_type_name = node.__class__.__name__
        pxm = util.loadIcon(nodewidgets.DefaultNode.iconName)

        if isinstance(node, (
                tuple,
                list,
        )):
            pxm = util.loadIcon(nodewidgets.SequenceNode.iconName)
        elif isinstance(node, (dict, )):
            pxm = util.loadIcon(nodewidgets.MappingNode.iconName)

        some_node_class = getattr(nodewidgets, '%sNode' % node_type_name, None)
        some_icon_name = getattr(some_node_class, 'iconName', None)

        if node_type_name == 'TechnicalTicker':
            ticker_pxm = util.loadIcon(node.symbol.lower())
            if not ticker_pxm.isNull():
                pxm = ticker_pxm
        elif some_icon_name is not None:
            pxm = util.loadIcon(some_icon_name)
        return pxm
Exemple #2
0
    def iconForPath(self, item):
        """ iconForPath(item) -> returns an icon appropriate to the item
    
        """
        if os.path.isdir(item):
            return util.loadIcon("folder")

        name = self.icons.get(os.path.splitext(item)[-1], None)
        if name:
            return util.loadIcon(name)
    def iconForPath(self, item):
        """ iconForPath(item) -> returns an icon appropriate to the item
    
        """
        if os.path.isdir(item):
            return util.loadIcon('folder')

        name = self.icons.get(os.path.splitext(item)[-1], None)
        if name:
            return util.loadIcon(name)
    def __init__(self, parent, ticker):
        fmtflt, zeroflt = '%.2f', 0.0
        args = (
            '%s' % ticker.current_data.get('position', 0),
            fmtflt % ticker.current_data.get('market_value', zeroflt),
            fmtflt % ticker.current_data.get(base.PriceTypes.Ask, zeroflt),
            fmtflt % ticker.current_data.get(base.PriceTypes.Bid, zeroflt),
            fmtflt % ticker.current_data.get(base.PriceTypes.Last, zeroflt),
        )
        args = (
            self,
            parent,
            ticker.symbol,
        ) + args
        qt.QListViewItem.__init__(*args)

        pxm = util.loadIcon(ticker.symbol.lower())
        self.setPixmap(0, pxm)

        self.ticker = ticker
        self.current = ticker.current_data
        self.previous = ticker.previous_data

        ## need to handle an updated config as this is static
        config = util.appConfig(util.groups.misc)
        self.useColor = config.readNumEntry(util.keys.colorTickers,
                                            util.defaults.colorTickers)
 def __init__(self, parent, node):
     BaseNodeListView.__init__(self, parent, node)
     for sym, pos in node.items():
         positems = [pos.position, pos.marketprice, pos.marketvalue]
         args = [self, sym, ] + [str(s) for s in positems]
         item = qt.QListViewItem(*args)
         item.setPixmap(0, util.loadIcon(sym.lower()))
     self.connect(self, util.sigDoubleClicked, self.handleShowTicker)
    def setupItem(self, contract, execution):
        """setupItem(...) -> build a list item

        """
        item = qt.QListViewItem(self)
        item.setPixmap(1, util.loadIcon(contract.symbol.lower()))
        vals = self.valueList(contract, execution)
        for c, v in enumerate(vals):
            item.setText(c, v)
Exemple #7
0
 def __init__(self, parent, node):
     qt.QIconView.__init__(self, parent)
     self.icons = {}
     for assm_key, assm_value in node.items():
         icon = self.icons[assm_key] = qt.QIconViewItem(self, assm_key)
         pxm = util.loadIcon(assm_value .__class__.__name__)
         icon.setPixmap(pxm)
     for setting_funcname, setting_value in self.settings:
         getattr(self, setting_funcname)(setting_value)
 def __init__(self, parent, node):
     qt.QIconView.__init__(self, parent)
     self.icons = {}
     for assm_key, assm_value in node.items():
         icon = self.icons[assm_key] = qt.QIconViewItem(self, assm_key)
         pxm = util.loadIcon(assm_value.__class__.__name__)
         icon.setPixmap(pxm)
     for setting_funcname, setting_value in self.settings:
         getattr(self, setting_funcname)(setting_value)
    def setupItem(self, contract, execution):
        """setupItem(...) -> build a list item

        """
        item = qt.QListViewItem(self)
        item.setPixmap(1, util.loadIcon(contract.symbol.lower()))
        vals = self.valueList(contract, execution)
        for c, v in enumerate(vals):
            item.setText(c, v)
Exemple #10
0
 def buildDock(self, key, icon, klass, parent=None, transient=False):
     """ buildDock(...) -> create and configure a dock widget
 
     """
     dock = self.createDockWidget(key, util.loadIcon(icon), parent, key, key)
     widget = klass(dock)
     dock.setWidget(widget)
     dock.setDockSite(kdeui.KDockWidget.DockFullSite)
     self.dockWidgets.append(dock)
     dock.transient = transient
     return dock, widget
Exemple #11
0
 def buildDock(self, key, icon, klass, parent=None, transient=False):
     """ buildDock(...) -> create and configure a dock widget
 
     """
     dock = self.createDockWidget(key, util.loadIcon(icon), parent, key, key)
     widget = klass(dock)
     dock.setWidget(widget)
     dock.setDockSite(kdeui.KDockWidget.DockFullSite)
     self.dockWidgets.append(dock)
     dock.transient = transient
     return dock, widget
 def __init__(self, parent, node):
     BaseNodeListView.__init__(self, parent, node)
     for sym, pos in node.items():
         positems = [pos.position, pos.marketprice, pos.marketvalue]
         args = [
             self,
             sym,
         ] + [str(s) for s in positems]
         item = qt.QListViewItem(*args)
         item.setPixmap(0, util.loadIcon(sym.lower()))
     self.connect(self, util.sigDoubleClicked, self.handleShowTicker)
    def setupItem(self, oid, omon, item):
        """setupItem(...) -> build a list view item

        """
        if not item:
            #item = qt.QListViewItem(self)
            item = OrderSupervisorListItem(self)
        item.om = (oid, omon)
        vals = self.valueList(oid, omon)
        for c, v in enumerate(vals):
            item.setText(c, v)
        sym = omon.contract.symbol.lower()
        item.setPixmap(1, util.loadIcon(sym))
Exemple #14
0
    def setupItem(self, oid, omon, item):
        """setupItem(...) -> build a list view item

        """
        if not item:
            #item = qt.QListViewItem(self)
            item = OrderSupervisorListItem(self)
        item.om = (oid, omon)
        vals = self.valueList(oid, omon)
        for c, v in enumerate(vals):
            item.setText(c, v)
        sym = omon.contract.symbol.lower()
        item.setPixmap(1, util.loadIcon(sym))
Exemple #15
0
    def getPixmap(self, node):
        """ getPixmap(node) -> returns an appropriate pixmap for a node

        """
        node_type_name = node.__class__.__name__
        pxm = util.loadIcon(nodewidgets.DefaultNode.iconName)

        if isinstance(node, (tuple, list, )):
            pxm = util.loadIcon(nodewidgets.SequenceNode.iconName)
        elif isinstance(node, (dict, )):
            pxm = util.loadIcon(nodewidgets.MappingNode.iconName)

        some_node_class = getattr(nodewidgets, '%sNode' % node_type_name, None)
        some_icon_name = getattr(some_node_class, 'iconName', None)

        if node_type_name == 'TechnicalTicker':
            ticker_pxm = util.loadIcon(node.symbol.lower())
            if not ticker_pxm.isNull():
                pxm = ticker_pxm
        elif some_icon_name is not None:
            pxm  = util.loadIcon(some_icon_name)
        return pxm
Exemple #16
0
    def setupFinal(self):
        """ setupFinal() -> various final setup operations

        """
        config = util.appConfig(util.groups.main)
        self.restoreWindowSize(config)

        xmlfile = os.path.join(self.appDir, "profitdevice.rc")
        self.createGUI(xmlfile, 0)

        kargs = kdecore.KCmdLineArgs.parsedArgs()

        if kargs.isSet("session"):
            self.newAction.activate()
            if kargs.isSet("start-tws"):
                self.startTwsAction.activate()

        ## apply the previous dock config and then delete it to keep it small
        config = util.appConfig()
        self.readDockConfig(config, util.groups.docks)
        config.deleteGroup(util.groups.docks, True)
        config.sync()

        ## looks nice with the sparkling icons
        pxm = util.loadIcon("tab_breakoff", size=kdecore.KIcon.SizeLarge)
        mpx = util.loadIcon("tab_breakoff", size=kdecore.KIcon.SizeSmall)
        kdecore.KWin.setIcons(self.winId(), pxm, mpx)

        config = util.appConfig()
        self.applyMainWindowSettings(config)
        self.toolBar().applySettings(config, None)
        self.pythonShell.onGuiComplete()

        ## optional parameter used because the main widget  isn't built yet
        link.connect(self.statusBar(), self)
        link.connect(self.summaryFrame, self)
Exemple #17
0
    def setupFinal(self):
        """ setupFinal() -> various final setup operations

        """
        config = util.appConfig(util.groups.main)
        self.restoreWindowSize(config)

        xmlfile = os.path.join(self.appDir, 'profitdevice.rc')
        self.createGUI(xmlfile, 0)

        kargs = kdecore.KCmdLineArgs.parsedArgs()

        if kargs.isSet('session'):
            self.newAction.activate()
            if kargs.isSet('start-tws'):
                self.startTwsAction.activate()

        ## apply the previous dock config and then delete it to keep it small
        config = util.appConfig()
        self.readDockConfig(config, util.groups.docks)
        config.deleteGroup(util.groups.docks, True)
        config.sync()

        ## looks nice with the sparkling icons
        pxm = util.loadIcon('tab_breakoff', size=kdecore.KIcon.SizeLarge)
        mpx = util.loadIcon('tab_breakoff', size=kdecore.KIcon.SizeSmall)
        kdecore.KWin.setIcons(self.winId(), pxm, mpx)

        config = util.appConfig()
        self.applyMainWindowSettings(config)
        self.toolBar().applySettings(config, None)
        self.pythonShell.onGuiComplete()

        ## optional parameter used because the main widget  isn't built yet
        link.connect(self.statusBar(), self)
        link.connect(self.summaryFrame, self)
Exemple #18
0
    def __init__(self, parent, name, descriptor):
        qt.QListViewItem.__init__(self, parent)
        self.setText(0, name)

        iconame = self.icons.get(descriptor, None) or self.icons.get(descriptor.__class__, None)
        if iconame:
            self.setPixmap(0, util.loadIcon(iconame))

        try:
            methods = descriptor.methods
        except (AttributeError,):
            pass
        else:
            if self.includeMethods:
                for name in methods:
                    CallableViewItem(self, name, "method")
    def __init__(self, parent, name, descriptor):
        qt.QListViewItem.__init__(self, parent)
        self.setText(0, name)

        iconame = self.icons.get(descriptor, None) or \
                  self.icons.get(descriptor.__class__, None)
        if iconame:
            self.setPixmap(0, util.loadIcon(iconame))

        try:
            methods = descriptor.methods
        except (AttributeError, ):
            pass
        else:
            if self.includeMethods:
                for name in methods:
                    CallableViewItem(self, name, 'method')
    def slotPortfolio(self, evt):
        """slotPortfolio(event) -> update the list view item

        """
        contract, position, market_price, market_value = \
            evt.contract, evt.position, evt.market_price, evt.market_value

        item = self.findItem(contract.symbol, 0) # ExactMatch | CaseSensitive
        if not item:
            args = [self, contract.symbol, ] 
            args += [str(s) for s in [position, market_price, market_value]]
            item = qt.QListViewItem(*args)
            item.setPixmap(0, util.loadIcon(contract.symbol.lower()))
        else:
            args = [position, market_price, market_value]
            for col, txt in enumerate([str(s) for s in args]):
                item.setText(col+1, txt)
    def __init__(self, parent=None):
        KDialogBase.__init__(self, KDialogBase.IconList, i18n(self.title),
                             self.buttonsMask, KDialogBase.Ok, parent,
                             self.title, False, True)
        self.pages = pages = []
        self.configWidgets = {}
        medium = kdecore.KIcon.SizeMedium

        for label, title, icon in self.pageDefs:
            builder = getattr(self, 'build%sPage' % (label, ))
            config = util.appConfig(label)
            icon = util.loadIcon(icon, size=medium)
            frame = self.addPage(i18n(label), i18n(title), icon)
            frame.groupLabel = label
            builder(config, frame)
            pages.append(frame)

        self.enableButton(KDialogBase.Help, False)
        self.enableButton(KDialogBase.Apply, False)
Exemple #22
0
    def __init__(self, parent=None):
        KDialogBase.__init__(self, KDialogBase.IconList, i18n(self.title), 
                             self.buttonsMask, KDialogBase.Ok, parent, 
                             self.title, False, True)
        self.pages = pages = []
        self.configWidgets = {}
        medium = kdecore.KIcon.SizeMedium

        for label, title, icon in self.pageDefs:
            builder = getattr(self, 'build%sPage' % (label, ))
            config = util.appConfig(label)
            icon = util.loadIcon(icon, size=medium)
            frame = self.addPage(i18n(label), i18n(title), icon)
            frame.groupLabel = label
            builder(config, frame)
            pages.append(frame)

        self.enableButton(KDialogBase.Help, False)
        self.enableButton(KDialogBase.Apply, False)
    def slotPortfolio(self, evt):
        """slotPortfolio(event) -> update the list view item

        """
        contract, position, market_price, market_value = \
            evt.contract, evt.position, evt.market_price, evt.market_value

        item = self.findItem(contract.symbol, 0)  # ExactMatch | CaseSensitive
        if not item:
            args = [
                self,
                contract.symbol,
            ]
            args += [str(s) for s in [position, market_price, market_value]]
            item = qt.QListViewItem(*args)
            item.setPixmap(0, util.loadIcon(contract.symbol.lower()))
        else:
            args = [position, market_price, market_value]
            for col, txt in enumerate([str(s) for s in args]):
                item.setText(col + 1, txt)
    def __init__(self, parent, ticker):
        fmtflt, zeroflt = "%.2f", 0.0
        args = (
            "%s" % ticker.current_data.get("position", 0),
            fmtflt % ticker.current_data.get("market_value", zeroflt),
            fmtflt % ticker.current_data.get(base.PriceTypes.Ask, zeroflt),
            fmtflt % ticker.current_data.get(base.PriceTypes.Bid, zeroflt),
            fmtflt % ticker.current_data.get(base.PriceTypes.Last, zeroflt),
        )
        args = (self, parent, ticker.symbol) + args
        qt.QListViewItem.__init__(*args)

        pxm = util.loadIcon(ticker.symbol.lower())
        self.setPixmap(0, pxm)

        self.ticker = ticker
        self.current = ticker.current_data
        self.previous = ticker.previous_data

        ## need to handle an updated config as this is static
        config = util.appConfig(util.groups.misc)
        self.useColor = config.readNumEntry(util.keys.colorTickers, util.defaults.colorTickers)
    def buildSessionPage(self, config, frame):
        """ buildSessionPage(...) -> constructs widgets for session settings

        """
        layout = qt.QGridLayout(frame, 10, 2, gridMargin, gridSpace)
        layout.setRowStretch(layout.numRows() + 10, 10)
        offset = 0
        for args in ((0, 0), (1, 2), (2, 0)):
            layout.setColStretch(*args)

        helplabel = qt.QLabel(sessionHelpText, frame)
        helplabel.setTextFormat(qt.Qt.RichText)
        layout.addMultiCellWidget(helplabel, 0, 0, 0, 2)
        offset += 1

        buildkeys = sessionBuilderKeys
        configrows = [offset + crow for crow in range(len(buildkeys))]
        configvals = [config.readEntry(ckey, '') for (bkey, ckey) in buildkeys]
        widgetdefs = zip(configrows, buildkeys, configvals)

        for index, (bkey, ckey), value in widgetdefs:
            label = qt.QLabel(bkey, frame)
            choose = kdeui.KPushButton('Select...', frame)
            choose.setPixmap(util.loadIcon('fileopen'))
            szwidth = choose.pixmap().width() + 8
            szheight = choose.pixmap().width() + 8
            choose.setFixedSize(szwidth, szheight)
            preview = choose.target = qt.QLineEdit(value, frame)

            for column, widget in enumerate((label, preview, choose)):
                layout.addWidget(widget, index, column)

            configrecord = (ckey, preview, '', preview.text, preview.setText)
            self.setConfigWidget(frame, configrecord)
            self.connect(choose, util.sigClicked, self.selectSysPath)
            self.connectChanged((preview, util.sigTextChanged))
Exemple #26
0
    def buildSessionPage(self, config, frame):
        """ buildSessionPage(...) -> constructs widgets for session settings

        """
        layout = qt.QGridLayout(frame, 10, 2, gridMargin, gridSpace)
        layout.setRowStretch(layout.numRows()+10, 10)
        offset = 0
        for args in ((0, 0), (1, 2), (2, 0)):
            layout.setColStretch(*args)

        helplabel = qt.QLabel(sessionHelpText, frame)
        helplabel.setTextFormat(qt.Qt.RichText)
        layout.addMultiCellWidget(helplabel, 0, 0, 0, 2)
        offset += 1

        buildkeys = sessionBuilderKeys
        configrows = [offset + crow for crow in range(len(buildkeys))]
        configvals = [config.readEntry(ckey, '') for (bkey, ckey) in buildkeys]
        widgetdefs = zip(configrows, buildkeys, configvals)

        for index, (bkey, ckey), value in widgetdefs:
            label = qt.QLabel(bkey, frame)
            choose = kdeui.KPushButton('Select...', frame)
            choose.setPixmap(util.loadIcon('fileopen'))
            szwidth = choose.pixmap().width() + 8
            szheight = choose.pixmap().width() + 8
            choose.setFixedSize(szwidth, szheight)
            preview = choose.target = qt.QLineEdit(value, frame)

            for column, widget in enumerate((label, preview, choose)):
                layout.addWidget(widget, index, column)

            configrecord = (ckey, preview, '', preview.text, preview.setText)
            self.setConfigWidget(frame, configrecord)
            self.connect(choose, util.sigClicked, self.selectSysPath)
            self.connectChanged((preview, util.sigTextChanged))