コード例 #1
0
    def __init__(self,
                 parent,
                 ID,
                 index,
                 title="Visualisation d'un livre",
                 size=(1250, 650)):
        wx.Frame.__init__(self,
                          parent,
                          ID,
                          title,
                          size=size,
                          style=wx.DEFAULT_FRAME_STYLE)

        self.virtualList = parent
        self.SetBackgroundColour("#FFFFFF")
        self.size = size  # Dimension de la fenêtre
        self.index = index  # Index of the ID of the item in the virtualList
        self.item = self.virtualList.getItem(self.index)  # Book object
        self.bitmapCouv = self.virtualList.principalFrame.lCouvBitmap[
            self.item.couverture]  # Bitmap de la couverture
        self.wTC = self.size[0]  # Longueur de base pour un texte

        # Contextual popup help bubble
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        self.initIcone()
        self.InitUI()

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.SetMinSize(self.size)
コード例 #2
0
    def OnInit(self):
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
        self.m_splash = iTrade_SplashScreen(self)
        self.m_splash.Show()
        return True
コード例 #3
0
def main():
    myapp = SingleInstance('{4A475CB1-CDB5-46b5-B221-4E36602FC47E}')
    useWxTaskBarIcon = True
    if myapp.alreadyRunning():
        logging.info('another instance of the sync tool as already running')
        # already running! i'm out of here!
        return

    if os.name == 'posix':
        # running on posix? is it ubuntu?
        # get back a tuple: (distname, version, id)
        tuple = platform.linux_distribution('Ubuntu')
        if tuple[1] >= '12.10':
            useWxTaskBarIcon = False

    if useWxTaskBarIcon:
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        requestQueue = Queue.Queue()
        messageQueue = Queue.Queue()
        app = wx.PySimpleApp()
        taskbar.TaskBar(requestQueue, messageQueue)

        cfg = config.Config()
        swiftCredentials = SwiftCredentials(cfg.authUrl, cfg.username,
                                            cfg.password)
        sys, node, r, v, m, processor = platform.uname()
        userAgent = "DigitalPandaSync/%s (%s %s %s; %s)" % (version.version,
                                                            sys, r, v, m)
        # an attempt to insert the user agent on all open requests
        # i don't actually know if this works!
        opener = urllib2.build_opener()
        opener.addheaders = [('User-agent', userAgent)]
        urllib2.install_opener(opener)

        swiftProvider = SwiftProvider(swiftCredentials, userAgent,
                                      messageQueue)
        mediatorThread = mediator.Mediator(swiftProvider, requestQueue,
                                           messageQueue)

        if (not swiftCredentials.authUrl or not swiftCredentials.username
                or not swiftCredentials.password):
            # no auth url? this must be the first time it's running
            messageQueue.put(messages.ShowSettings())

        mediatorThread.start()
        try:
            app.MainLoop()
        finally:
            mediatorThread.stop()
    else:
        gtxtaskbar.run()

    del myapp
コード例 #4
0
    def __init__(self,
                 parent,
                 ID,
                 title,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE):
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)
        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wx.Python extension is concerned.
        self.this = pre.this
        sizer = wx.BoxSizer(wx.VERTICAL)
        box = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self, -1, "echangelog")
        label.SetHelpText(
            "Enter text to pass to echangelog. Leave blank for multi-line entry (xterm will be launched)."
        )
        box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.inp = wx.TextCtrl(self, -1, "", size=(280, -1))
        self.inp.SetHelpText(
            "Enter text to pass to echangelog. Leave blank for multi-line entry (xterm will be launched)."
        )
        box.Add(self.inp, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        box = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)
        box = wx.BoxSizer(wx.HORIZONTAL)
        btn = wx.Button(self, wx.ID_OK, " OK ")
        btn.SetDefault()
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        btn = wx.Button(self, wx.ID_CANCEL, " Cancel ")
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        btn = wx.ContextHelpButton(self)
        box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
コード例 #5
0
    def __init__(self, parent, titre="", size=wx.DefaultSize):
        u"""S'il s'agit d'un dialogue pour la création d'objets,
        le titre par défaut est généré automatiquement à partir de l'attribut de classe 'objet'."""

        if self.objet and not titre:
            titre = u"Créer " + self.objet.titre()

        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(
            parent, -1, titre, wx.DefaultPosition, size,
            wx.DEFAULT_DIALOG_STYLE
        )  # si l'objet est nul, ce n'est pas une boite de creation d'objet

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.PostCreate(pre)

        # Now continue with the normal construction of the dialog
        # contents
        ##        self.parent = parent
        # En cas de changement d'onglet, cela permet de pointer toujours sur l'onglet initial
        self.onglet_actuel = parent.onglet_actuel
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.champs = {}

        self.Bind(wx.EVT_CHAR, self.OnChar)

        if self.objet:
            self.ajoute(
                [("Nom %s : " % self.objet.titre("du", False)), ("nom", 10)],
                u"Entrez le nom de l'objet. Exemples : A, AB, Cercle, M2...")
コード例 #6
0
ファイル: application.py プロジェクト: franzmelchiori/alyvix
 def OnInit(self):
     # Needed for SetToolTipString to work
     wx.HelpProvider_Set(wx.SimpleHelpProvider())
     self.settings = RideSettings()
     librarydatabase.initialize_database()
     self.preferences = Preferences(self.settings)
     self.namespace = Namespace(self.settings)
     self._controller = Project(self.namespace, self.settings)
     self.frame = RideFrame(self, self._controller)
     self._editor_provider = EditorProvider()
     self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                        coreplugins.get_core_plugins())
     self._plugin_loader.enable_plugins()
     self.editor = self._get_editor()
     self.editor.show()
     self._load_data()
     self.frame.tree.populate(self.model)
     self.frame.tree.set_editor(self.editor)
     self._publish_system_info()
     if self._updatecheck:
         UpdateNotifierController(self.settings).notify_update_if_needed(UpdateDialog)
     wx.CallLater(200, ReleaseNotes(self).bring_to_front)
     return True
コード例 #7
0
	def OnInit(self):
		"""
		Create the application's main window
		"""
		self.SetAppName("BioImageXD")
		iconpath = scripting.get_icon_dir()

		splashimage = os.path.join(iconpath, "splash3.png")
		self.splash = GUI.SplashScreen.SplashScreen(None, duration = 99000, bitmapfile = splashimage)
		self.splash.Show()
		self.splash.SetMessage("Loading BioImageXD...")
		provider = wx.SimpleHelpProvider()
		wx.HelpProvider_Set(provider)

		self.mainwin = GUI.MainWindow.MainWindow(None, -1, self, self.splash)
		self.mainwin.config = wx.Config("BioImageXD", style = wx.CONFIG_USE_LOCAL_FILE)
		scripting.app = self
		scripting.mainWindow = self.mainwin

		self.mainwin.Show(True)
		self.SetTopWindow(self.mainwin)

		return True
コード例 #8
0
ファイル: mainframe.py プロジェクト: kassenov/sumo
import sys, os, string, time
from collections import OrderedDict

#import metacanvas_editor,metanet_editor,surveymask_editor#, metanet_editor_standalone
from wxmisc import KEYMAP, AgileMenuMixin, AgileToolbarFrameMixin, AgileStatusbar, AgileMenubar

from os.path import *
from os import getcwd

import objpanel
from agilepy.lib_base.logger import Logger

# We first have to set an application-wide help provider.  Normally you
# would do this in your app's OnInit or in other startup code...
provider = wx.SimpleHelpProvider()
wx.HelpProvider_Set(provider)


def make_moduleguis(dirlist):
    moduleguilist = []
    for modulesdir in dirlist:
        make_moduleguilist(moduleguilist, modulesdir)
        #print 'make_moduleguis: moduleguilist=\n',moduleguilist

    moduleguilist.sort()
    moduleguis = OrderedDict()
    for initpriority, wxgui in moduleguilist:
        moduleguis[wxgui.get_ident()] = wxgui
    return moduleguis

コード例 #9
0
ファイル: EmergeDialog.py プロジェクト: aaferrari/abeni-git
    def __init__(self, parent, ID, title,
                 pos=wx.DefaultPosition, size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE):
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)
        self.parent = parent
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)
        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wx.Python extension is concerned.
        self.this = pre.this
        sizer = wx.BoxSizer(wx.VERTICAL)
        box = wx.BoxSizer(wx.HORIZONTAL)

        useLabel = wx.StaticText(self, -1, "USE=")
        useLabel.SetHelpText("Enter any USE variables for the emerge command.")
        box.Add(useLabel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.use = wx.TextCtrl(self, -1, parent.pref["use"], size=(100,-1))
        self.use.SetHelpText("Enter any USE variables for the emerge command.")
        box.Add(self.use, 1, wx.ALIGN_CENTRE|wx.ALL, 5)

        featuresLabel = wx.StaticText(self, -1, "FEATURES=")
        featuresLabel.SetHelpText("Enter any variables for FEATURES.")
        box.Add(featuresLabel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.features = wx.TextCtrl(self, -1, parent.pref["features"], size=(100,-1))
        self.features.SetHelpText("Enter any variables for FEATURES.")
        box.Add(self.features, 1, wx.ALIGN_CENTRE|wx.ALL, 5)

        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        box = wx.BoxSizer(wx.HORIZONTAL)

        self.cat_pack_ver = utils.GetCatPackVer(parent)

        cmd = "emerge --oneshot --nospinner =%s"  % self.cat_pack_ver

        pretend_cmd = "emerge --nospinner -pv =%s"  % self.cat_pack_ver

        self.emerge = wx.TextCtrl(self, -1, cmd, size=(560,-1))
        self.emerge.SetHelpText("Enter any options for the emerge command.")
        box.Add(self.emerge, 1, wx.ALIGN_CENTRE|wx.ALL, 5)
        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        box = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
        box = wx.BoxSizer(wx.HORIZONTAL)

        btn = wx.Button(self, wx.ID_OK, " Emerge ")
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        wx.ID_PRETEND_EMERGE = wx.NewId()
        btn = wx.Button(self, wx.ID_PRETEND_EMERGE, " Pretend ")
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        wx.EVT_BUTTON(btn, wx.ID_PRETEND_EMERGE, self.OnPretendButton)


        btn = wx.Button(self, wx.ID_CANCEL, " Cancel ")
        btn.SetDefault()
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        btn = wx.ContextHelpButton(self)
        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
コード例 #10
0
ファイル: needswx.py プロジェクト: kk7nc/NGS
    def __init__(
            self,
            option_parser,  #The OptionParser object
            parent=None,
            ID=0,
            title='Program Options',
            pos=wx.DefaultPosition,
            size=wx.DefaultSize,
            style=wx.DEFAULT_DIALOG_STYLE,
            name='OptparseDialog',
            values=None,
            args=False):

        self.option_parser = option_parser
        if values == None:
            values = option_parser.get_defaults()

        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        top_label_text = '%s %s' % (option_parser.get_prog_name(),
                                    option_parser.get_version())
        label = wx.StaticText(self, -1, top_label_text)
        sizer2.Add(label, 0, wx.GROW | wx.ALIGN_LEFT | wx.ALL, 5)
        if wx.Platform != "__WXMSW__":
            sizer2.AddStretchSpacer(-1)
            btn = wx.ContextHelpButton(self)
            sizer2.Add(btn, 0, wx.ALIGN_RIGHT | wx.ALL)
        sizer.Add(sizer2, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(
            line, 0,
            wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP | wx.LEFT,
            5)

        nb = wx.Notebook(self, wx.ID_ANY)

        self.option_controls = {}
        self.option_controls.update(
            self.set_panel(nb, option_parser.option_list, values, 'Options'))
        for g in option_parser.option_groups:
            self.option_controls.update(
                self.set_panel(nb, g.option_list, values, g.title))
        if args:
            self.args_ctrl = self.set_args_panel(nb, values, 'Arguments')
        else:
            self.args_ctrl = None

        sizer.Add(
            nb, 0,
            wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP | wx.LEFT,
            5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(
            line, 0,
            wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP | wx.LEFT,
            5)

        btnsizer = wx.BoxSizer(wx.HORIZONTAL)

        btn = wx.Button(self, wx.ID_CANCEL)
        # btn.SetHelpText("The OK button completes the dialog")
        btnsizer.Add(btn, 0, wx.ALL, 5)

        btnsizer.AddSpacer((100, -1))
        btn = wx.Button(self, wx.ID_CLEAR, label="Reset")
        btn.Bind(wx.EVT_BUTTON, self.closeDialog)
        btnsizer.Add(btn, 0, wx.ALL, 5)

        btnsizer.AddSpacer((100, -1))
        btn = wx.Button(self, wx.ID_OK)
        btn.SetDefault()
        # btn.SetHelpText("The Cancel button cancels the dialog.")
        btnsizer.Add(btn, 0, wx.ALL, 5)

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER,
                  wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
コード例 #11
0
    def __init__(self,
                 optParser,
                 title,
                 parent=None,
                 ID=0,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE | wx.THICK_FRAME):
        """Function for initialization"""

        modis_icon = wx.Icon('/home/lucadelu/github/pyModis/pyModis.ico',
                             wx.BITMAP_TYPE_ICO)
        #        self.SetIcon(modis_icon)
        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)
        self.CenterOnScreen()
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.args_ctrl = []
        self.option_controls = {}

        #       IN THE TOP OF GUI THERE WAS THE NAME OF THE SCRIPT, BUT NOW IT IS IN
        #       THE TITLE

        #        top_label_text = '%s %s' % (optParser.get_prog_name(),
        #                                     optParser.get_version())
        #        label = wx.StaticText(self, -1, top_label_text)
        #        sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        # Add a text control for entering args

        arg = self._checkArg(optParser.get_prog_name())
        sizer.Add(arg, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        self.browse_option_map = {}
        # Add controls for all the options
        for option in optParser.list_of_option:
            if option.dest is None:
                continue

            if option.help is None:
                option.help = u''

            if checkLabel(option) == 'Formats':
                continue

            box = wx.BoxSizer(wx.HORIZONTAL)
            if 'store' == option.action:
                label = wx.StaticText(self, -1, checkLabel(option))
                label.SetHelpText(
                    option.help.replace(' [default=%default]', ''))
                box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

                if 'choice' == option.type:
                    choices = list(set(option.choices))
                    if optparse.NO_DEFAULT == option.default:
                        option.default = choices[0]
                    ctrl = wx.ComboBox(self,
                                       -1,
                                       choices=choices,
                                       value=option.default,
                                       size=TEXTCTRL_SIZE,
                                       style=wx.CB_DROPDOWN | wx.CB_READONLY
                                       | wx.CB_SORT)
                elif option.type in ['file', 'output']:
                    if option.type == 'file':
                        fmode = wx.OPEN
                    elif option.type == 'output':
                        fmode = wx.SAVE
                    ctrl = filebrowse.FileBrowseButton(
                        self,
                        id=wx.ID_ANY,
                        fileMask='*',
                        labelText='',
                        dialogTitle='Choose output file',
                        buttonText='Browse',
                        startDirectory=os.getcwd(),
                        fileMode=fmode,
                        size=TEXTCTRL_SIZE)
                elif option.type == 'directory':
                    ctrl = filebrowse.DirBrowseButton(
                        self,
                        id=wx.ID_ANY,
                        labelText='',
                        dialogTitle='Choose output file',
                        buttonText='Browse',
                        startDirectory=os.getcwd(),
                        size=TEXTCTRL_SIZE)
                else:
                    if 'MULTILINE' in option.help:
                        ctrl = wx.TextCtrl(self,
                                           -1,
                                           "",
                                           size=(400, 100),
                                           style=wx.TE_MULTILINE
                                           | wx.TE_PROCESS_ENTER)
                    else:
                        ctrl = wx.TextCtrl(self, -1, "", size=TEXTCTRL_SIZE)

                    if (option.default != optparse.NO_DEFAULT) and \
                       (option.default is not None):
                        ctrl.Value = str(option.default)

                box.Add(ctrl, 1, wx.ALIGN_RIGHT | wx.ALL, 5)

            elif option.action in ('store_true', 'store_false'):
                ctrl = wx.CheckBox(self,
                                   -1,
                                   checkLabel(option),
                                   size=(300, -1))
                box.Add(ctrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
            elif option.action == 'group_name':
                label = wx.StaticText(self, -1, checkLabel(option))
                font = wx.Font(12, wx.DECORATIVE, wx.NORMAL, wx.BOLD)
                label.SetFont(font)
                box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
                ctrl = None
            else:
                raise NotImplementedError(
                    'Unknown option action: '
                    '{act}'.format(act=repr(option.action)))
            if ctrl:
                ctrl.SetHelpText(option.help.replace(' [default=%default]',
                                                     ''))
                self.option_controls[option] = ctrl
            sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0,
                  wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
コード例 #12
0
    def __init__(
            self,
            option_parser, #The OptionParser object
            parent = None,
            ID = 0,
            title = 'Optparse Dialog',
            pos=wx.DefaultPosition,
            size=wx.DefaultSize,
            style=wx.DEFAULT_DIALOG_STYLE,
            name = 'OptparseDialog',
        ):

        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.option_controls = {}

        top_label_text = '%s %s' % ( option_parser.get_prog_name(),
                                     option_parser.get_version() )
        label = wx.StaticText(self, -1, top_label_text)
        sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        self.browse_option_map = {}

        # Add controls for all the options
        for option in option_parser.option_list:
            if option.dest is None:
                continue

            if option.help is None:
                option.help = u''

            box = wx.BoxSizer(wx.HORIZONTAL)
            if 'store' == option.action:
                label = wx.StaticText(self, -1, option.dest )
                label.SetHelpText( option.help )
                box.Add( label, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )

                if 'choice' == option.type:
                    if optparse.NO_DEFAULT == option.default:
                        option.default = option.choices[0]
                    ctrl = wx.ComboBox(
                        self, -1, choices = option.choices,
                        value = option.default,
                        style = wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT
                    )
                else:
                    if 'MULTILINE' in option.help:
                        ctrl = wx.TextCtrl( self, -1, "", size=(300,100), style = wx.TE_MULTILINE|wx.TE_PROCESS_ENTER )
                    else:
                        ctrl = wx.TextCtrl( self, -1, "", size=(300,-1) )

                    if ( option.default != optparse.NO_DEFAULT ) and \
                       ( option.default is not None ):
                        ctrl.Value = unicode( option.default )

                box.Add( ctrl, 1, wx.ALIGN_CENTRE|wx.ALL, 5 )

                if option.type in ['file', 'directory']:
                    browse = wx.Button(self, label='...')
                    browse.SetHelpText( 'Click to open %s browser' % (option.type) )
                    self.browse_option_map[browse.GetId()] = option, ctrl
                    wx.EVT_BUTTON(self, browse.GetId(), self.OnSelectPath)
                    box.Add( browse, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )

            elif option.action in ( 'store_true', 'store_false' ):
                ctrl = wx.CheckBox( self, -1, option.dest, size = ( 300, -1 ) )
                box.Add( ctrl, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
            else:
                raise NotImplementedError ( 'Unknown option action: %s' % repr( option.action ) )

            ctrl.SetHelpText( option.help )
            sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

            self.option_controls[ option ] = ctrl

        # Add a text control for entering args
        box = wx.BoxSizer( wx.HORIZONTAL )
        label = wx.StaticText(self, -1, 'args' )
        label.SetHelpText( 'This is the place to enter the args' )

        self.args_ctrl = wx.TextCtrl( self, -1, '', size = ( -1, 100 ),
                            style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER )
        self.args_ctrl.SetHelpText(
'''Args can either be separated by a space or a newline
Args the contain spaces must be entered like so: "arg with sapce"
'''
        )
        box.Add( label, 0, wx.ALIGN_CENTRE | wx.ALL, 5 )
        box.Add( self.args_ctrl, 1, wx.ALIGN_CENTRE | wx.ALL, 5 )

        sizer.Add( box , 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
コード例 #13
0
    def __init__(self, option_parser):

        self.option_parser = option_parser
        self.option_parser.result = None 
        self.capture_std_streams()
        run_methods = getattr(option_parser, 'run_methods', ['subprocess', 'subcommand'])

        self.option_controls = {}
        self.browse_option_map = {}
        self.process_list = []

        wx.Frame.__init__(self, None, title="Optparse Dialog: %s" % (os.path.basename(sys.argv[0])))
        p = wx.Panel(self)

        provider = wx.SimpleHelpProvider()
        wx.HelpProvider_Set(provider)

        nb = wx.Notebook(p)
        
        option_panel = OptionPanel(nb, option_parser.option_list, self)
        option_panel.SetHelpText (option_parser.description or 'Main options')
        nb.AddPage(option_panel, 'Main Options')

        pages = []
        for group in option_parser.option_groups:
            if group in pages:
                continue
            option_panel = OptionPanel(nb, group.option_list, self)
            option_panel.SetHelpText (group.description or 'Group options')
            nb.AddPage(option_panel, group.title)
            pages.append(group)

        sizer_a = wx.BoxSizer (wx.VERTICAL)
        self.args_ctrl = args_ctrl = wx.TextCtrl(p, -1, '', size = ( -1, 80 ), 
                                                 style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER )
        args_ctrl.SetHelpText ('''\
Arguments can be either separated by a space or a newline. Arguments
that contain spaces must be entered like so: "arg with space"\
''')
        label = wx.StaticText(p, -1, 'Arguments:' )
        label.SetHelpText( 'Enter arguments here' )
        sizer_a.Add (label, 0, wx.EXPAND)
        sizer_a.Add (args_ctrl, 0, wx.EXPAND)
        args_ctrl.Fit ()

        sizer_b = wx.BoxSizer (wx.HORIZONTAL)


        cancel_b = wx.Button(p, -1, 'Cancel')
        cancel_b.SetHelpText('Cancel the program without saving')

        if debug>1:
            test_b = wx.Button(p, -1, 'Test')
            test_b.SetHelpText('Test options')

        run_b = None
        if option_parser.runner is not None or 1:
            self.run_b = run_b = wx.Button(p, -1, 'Run')
            run_b.SetHelpText('Run script with specified options and arguments.')

        batch_b = None
        if 0:
            self.batch_b = batch_b = wx.Button(p, -1, 'Batch')
            batch_b.SetHelpText('Run script with specified options and arguments in batch mode and exit.')

        self.exit_b = exit_b = wx.Button(p, -1, 'Exit')
        exit_b.SetHelpText('Exit without running the script. Any running process will be terminated.')

        send_b = None
        if bug_report_email:
            send_b = wx.Button (p, -1, 'Send Bug Report')
            send_b.SetHelpText ('Send bug report to %r. The bug report will include some environment data, used options and arguments, the content of the log window. If you want to add some notes then enter them to log window before pressing the Send Bug Report button.' % (bug_report_email))

        runner_mth = None
        if multiprocessing is None or option_parser.runner is None:
            self.run_method = 'subcommand'
        else:
            self.run_method = run_methods[0]
            if len (run_methods)>1:
                runner_mth = wx.ComboBox(
                    p, -1, choices = run_methods,
                    value = run_methods[0],
                    style = wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT 
                    )
                runner_mth.SetHelpText ('Specify how to run application. Selecting subprocess means using multiprocessing.Process. Selecting subcommand means running the application with --no-gui option and using specified options. If application uses wx then one should select subcommand.')

        sizer_b.Add(cancel_b, 0, wx.ALL, 2)
        if debug>1:
            sizer_b.Add(test_b, 0, wx.ALL, 2)
        if run_b is not None:
            sizer_b.Add(run_b, 0, wx.ALL, 2)
            if runner_mth is not None:
                sizer_b.Add(runner_mth, 0, wx.ALL, 2)
        if batch_b is not None:
            sizer_b.Add(batch_b, 0, wx.ALL, 2)
        sizer_b.Add(exit_b, 0, wx.ALL, 2)
        if send_b is not None:
            sizer_b.Add(send_b, 0, wx.ALL, 2)

        self.log_window = log_window = wx.TextCtrl (p, -1, '', style = wx.TE_MULTILINE,
                                                    size = ( -1, 120 ))
        log_window.SetFont(wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL, False))
        log_window.SetHelpText ('Shows the standard output and error messages of a running process.')

        if wx.Platform != "__WXMSW__" or 1:
            help_b = wx.ContextHelpButton(p)
            sizer_b.Add((20,20),1)
            sizer_b.Add(help_b, 0, wx.RIGHT, 2)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(nb, 0, wx.EXPAND)
        sizer.Add(sizer_a, 0, wx.EXPAND, 5 )
        sizer.Add(sizer_b, 0, wx.EXPAND|wx.BOTTOM, 5)
        sizer.Add(log_window, 1, wx.EXPAND)

        p.SetSizer(sizer)
        p.Fit ()
        sizer.SetSizeHints(p)

        self.Fit ()

        self.timer = wx.Timer(self)


        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=cancel_b.GetId())
        if run_b is not None:
            self.Bind(wx.EVT_BUTTON, self.OnRun, id=run_b.GetId())
            if runner_mth is not None:
                self.Bind(wx.EVT_COMBOBOX, self.OnSelectRunnerMethod, id=runner_mth.GetId())
        if batch_b is not None:
            self.Bind(wx.EVT_BUTTON, self.OnBatch, id=batch_b.GetId())
        if debug>1:
            self.Bind(wx.EVT_BUTTON, self.OnTest, id=test_b.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnExit, id=exit_b.GetId())
        if send_b is not None:
            self.Bind(wx.EVT_BUTTON, self.OnSend, id=send_b.GetId())
        self.Bind(wx.EVT_IDLE, self.OnUpdateLogWindow)
        self.Bind(wx.EVT_TIMER, self.OnUpdateLogWindow, self.timer)

        self.previous_position = 0
        self._running_count = 0
コード例 #14
0
    def __init__(self,
                 parent,
                 id=-1,
                 title='Normalization Settings',
                 **kwargs):
        kwargs['size'] = kwargs.get('size', (500, 500))
        wx.Frame.__init__(self, parent, id, title=title, **kwargs)
        CPATool.__init__(self)
        wx.HelpProvider_Set(wx.SimpleHelpProvider())

        self.n_steps = 1

        self.SetBackgroundColour("white")

        #
        # Define the controls
        #
        tables = ([p.image_table]
                  or []) + ([p.object_table] if p.object_table else [])
        self.table_choice = wx.Choice(self, -1, choices=tables)
        select_all_btn = wx.Button(self, -1, 'Select all columns')
        select_all_btn.SetHelpText("Click this button to check all columns.")

        self.table_choice.Select(0)
        self.table_choice.SetHelpText(
            "Select the table containing the measurement columns to normalize."
        )
        self.col_choices = wx.CheckListBox(self,
                                           -1,
                                           choices=[],
                                           size=(-1, 100))
        self.col_choices.SetHelpText(
            "Select the measurement columns to normalize. More than one column may be selected. "
            "The normalization steps below will be performed on all columns.")
        add_norm_step_btn = wx.Button(self, -1, 'Add normalization step')
        add_norm_step_btn.SetHelpText(
            "Click this button to add another normalization to perform. "
            "The normalizations are performed from top to bottom, with the "
            "results from one step being used as input into the following step."
        )
        self.norm_meas_checkbox = wx.CheckBox(self, -1,
                                              'Normalized measurements')
        self.norm_meas_checkbox.Set3StateValue(True)
        self.norm_meas_checkbox.SetHelpText(
            "Write a column of normalized measurements to the output table. "
            "This column ihas the same name as the input, with the suffix '_NmV'"
        )
        self.norm_factor_checkbox = wx.CheckBox(self, -1,
                                                'Normalization factors')
        self.norm_factor_checkbox.SetHelpText(
            "Write a column of normalization factors to the output table. "
            "This column ihas the same name as the input, with the suffix '_NmF' added."
        )
        self.output_table = wx.TextCtrl(self,
                                        -1,
                                        'normalized_measurements',
                                        size=(200, -1))
        self.output_table.SetHelpText(
            "Enter the name of the output table which will contain "
            "your normalized measurements and/or the normalization factors.\n "
            "The text will appear orange if the table already exists "
            "in the database. The output table will be linked to the existing "
            "tables so it is usable immediately.")
        self.help_btn = wx.ContextHelpButton(self)
        self.do_norm_btn = wx.Button(self, wx.ID_OK, 'Perform Normalization')
        self.do_norm_btn.SetHelpText(
            "Once you have adjusted the settings, click this button to start normalization "
            "and write the results to the output table. A progress bar will inform you "
            "of the normalization status.")

        self.boxes = []

        self.SetSizer(wx.BoxSizer(wx.VERTICAL))
        sz = wx.BoxSizer(wx.HORIZONTAL)
        sz.Add(wx.StaticText(self, -1, 'Select a table:'), 0,
               wx.EXPAND | wx.RIGHT, 5)
        sz.Add(self.table_choice, 0)
        sz.Add(select_all_btn, 0, wx.EXPAND)
        self.Sizer.Add(sz, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 15)
        self.col_choices_desc = wx.StaticText(
            self, -1, 'Select measurements to normalize:')
        self.Sizer.Add(self.col_choices_desc, 0,
                       wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 15)
        self.Sizer.AddSpacer((-1, 5))
        self.Sizer.Add(self.col_choices, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 15)

        #
        # Lay out the first normalization step inside a scrolled window
        # and a static box sizer.
        #
        self.Sizer.Add(
            wx.StaticText(
                self, -1,
                'Specify the normalization steps you want to perform:'), 0,
            wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 15)
        self.sw = wx.ScrolledWindow(self)
        sbs = wx.StaticBoxSizer(wx.StaticBox(self.sw, label=''), wx.VERTICAL)
        nsp = NormalizationStepPanel(self.sw, allow_delete=False)
        self.norm_steps = [nsp]
        self.boxes = [sbs]
        sbs.Add(nsp, 0, wx.EXPAND)
        self.sw.Sizer = wx.BoxSizer(wx.VERTICAL)
        self.sw.Sizer.Add(sbs, 0, wx.EXPAND)
        (w, h) = self.sw.Sizer.GetSize()
        self.sw.SetScrollbars(20, 20, w / 20, h / 20, 0, 0)
        self.Sizer.Add(self.sw, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 15)

        sz = wx.BoxSizer(wx.HORIZONTAL)
        sz.AddStretchSpacer()
        sz.Add(add_norm_step_btn, 0, wx.EXPAND)
        self.Sizer.Add(sz, 0, wx.EXPAND | wx.RIGHT, 15)

        sz = wx.BoxSizer(wx.HORIZONTAL)
        self.output_table_desc = wx.StaticText(self, -1,
                                               'Name your output table:')
        sz.Add(self.output_table_desc, 0, wx.EXPAND | wx.RIGHT, 5)
        sz.Add(self.output_table, 0, wx.EXPAND)
        self.Sizer.Add(sz, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 15)

        sz = wx.BoxSizer(wx.HORIZONTAL)
        self.output_format_desc = wx.StaticText(self, -1, 'Output columns:')
        sz.Add(self.output_format_desc, 0, wx.EXPAND | wx.RIGHT, 5)
        sz.Add(self.norm_meas_checkbox, 0, wx.EXPAND | wx.RIGHT, 5)
        sz.Add(self.norm_factor_checkbox, 0, wx.EXPAND)
        self.Sizer.Add(sz, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 15)

        sz = wx.BoxSizer(wx.HORIZONTAL)
        sz.Add(self.help_btn)
        sz.AddStretchSpacer()
        sz.Add(self.do_norm_btn)
        self.Sizer.Add(sz, 0, wx.EXPAND | wx.ALL, 15)

        self.table_choice.Bind(wx.EVT_CHOICE, self.on_select_table)
        select_all_btn.Bind(wx.EVT_BUTTON, self.on_select_all_columns)
        add_norm_step_btn.Bind(wx.EVT_BUTTON, self.on_add_norm_step)
        self.col_choices.Bind(wx.EVT_CHECKLISTBOX, lambda e: self.validate())
        self.norm_meas_checkbox.Bind(wx.EVT_CHECKBOX,
                                     lambda e: self.validate())
        self.norm_factor_checkbox.Bind(wx.EVT_CHECKBOX,
                                       lambda e: self.validate())
        self.output_table.Bind(wx.EVT_TEXT, lambda e: self.validate())
        self.do_norm_btn.Bind(wx.EVT_BUTTON, self.on_do_normalization)

        self.update_measurement_choices()
        self.validate()