Ejemplo n.º 1
0
 def EcritStatusbar(self, texte=u""):
     try :
         topWindow = wx.GetApp().GetTopWindow() 
         topWindow.SetStatusText(texte)
     except : 
         pass
Ejemplo n.º 2
0
 def handle(self):
     data = self.request.recv(1024)
     wx.GetApp().TxtCtr.SetValue(data)
     response = 'string length: %d' % len(data)
     #        print 'responding to',data,'with',response
     self.request.send(response)
Ejemplo n.º 3
0
 def on_close(self, event):
     wx.GetApp().ExitMainLoop()
Ejemplo n.º 4
0
    def determine_output_file_type(cls, output_file):  #pylint: disable=invalid-name
        """
        Determines output File Type (partition or device).

        Returns:
            tuple(string, bool).

                1st element:                The type of the output file. "Partition",
                                            "Device", "LUKS", or "LVM".

                2nd element:                True - success, False - failed.
        """

        #Set a default.
        output_file_type = "unknown"

        #--------------- USING PARTED TO DETECT PARTITION TABLES AND FILESYSTEMS ---------------
        #If list of partitions is empty (or 1 partition), we have a partition.
        retval, output = CoreTools.start_process(cmd="parted -sm '" +
                                                 output_file + "' print",
                                                 return_output=True,
                                                 privileged=True)

        #NOTE: Exit code 1 on CD images, but still works.
        if retval not in (0, 1):
            return "unknown", False

        temp_output = output.split("\n")

        #Clean it up - errors from parted can mess this up.
        output = "unknown"

        for line in temp_output:
            if line == "":
                continue

            #All output lines end with a semicolon, and the first line can be ignored.
            if line[-1] == ";" and "BYT;" not in line:
                output = line
                break

        output = output.split(":")

        #FIXME will break if output file path has spaces in the name.
        #We want field 6 - the partition table type.
        try:
            #The type will be "loop" if this is a partition.
            if output[5] == "loop":
                output_file_type = "Partition"

            #If we have any valid partition table, this is a device.
            elif output[5] in ("msdos", "gpt", "mac", "pc98", "sun", "dvh",
                               "bsd", "amiga", "aix", "atari"):

                output_file_type = "Device"

        except IndexError:
            pass

        #--------------- DETECTING LUKS AND LVM CONTAINERS ---------------
        #Check if this is a LUKS or LVM container if parted didn't help.
        if output_file_type == "unknown":
            #Check for LUKS.
            if CoreTools.start_process(cmd="cryptsetup isLuks '" +
                                       output_file + "'",
                                       privileged=True) == 0:

                output_file_type = "LUKS"

            #Check for LVM.
            output = CoreTools.start_process(cmd="file -s '" + output_file +
                                             "'",
                                             return_output=True,
                                             privileged=True)[1]

            if "LVM" in output:
                output_file_type = "LVM"

        #Ask the user if we don't know what type the input file is.
        if output_file_type == "unknown":
            choices = [
                "Partition (single file system or CD/DVD image)",
                "Device (multiple partitions)",
                "LUKS (encrypted storage) Container", "LVM Container"
            ]

            dlg = wx.SingleChoiceDialog(
                wx.GetApp().TopWindow.panel,
                "What type of file/device did you recover from?",
                "DDRescue-GUI - Question",
                choices,
                pos=wx.DefaultPosition)

            if dlg.ShowModal() == wx.ID_OK:
                answer = dlg.GetStringSelection()
                dlg.Destroy()

            #If the user doesn't answer, give up.
            else:
                dlg.Destroy()
                return "unknown", False

            #The first word in our human-readable choices is the type.
            output_file_type = answer.split()[0]

        return output_file_type, True
Ejemplo n.º 5
0
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, wx.ID_ANY, name='update_event')

        #set some frame properties
        self.Bind(wx.EVT_CLOSE, self.OnExit)
        self.SetIcon(wx.Icon(wx.GetApp().engine.icon, wx.BITMAP_TYPE_ICO))
        p = wx.Panel(self)
        #widgets
        self.stSupplier = wx.StaticText(p, wx.ID_ANY, 'Company')
        self.cbSuppliers = wx.ComboBox(p,
                                       ID_SUPPLIERS,
                                       size=(wx.GetApp().engine.get_font() *
                                             20, -1),
                                       style=wx.CB_READONLY)
        self.cbSuppliers.SetToolTipString('Select a supplier.')

        self.stCategory = wx.StaticText(p, wx.ID_ANY, 'Category')
        self.cbCategories = wx.ComboBox(p,
                                        ID_CATEGORIES,
                                        size=(wx.GetApp().engine.get_font() *
                                              20, -1),
                                        style=wx.CB_READONLY)
        self.cbCategories.SetToolTipString('Select a category.')

        self.stReference = wx.StaticText(p, wx.ID_ANY, 'Reference')
        self.txReference = wx.TextCtrl(p,
                                       wx.ID_ANY,
                                       'No',
                                       size=(wx.GetApp().engine.get_font() *
                                             20, -1))
        self.txReference.SetMaxLength(30)
        message = 'Insert reference.\nMax 30 chars.'
        self.txReference.SetToolTipString(message)
        #to fix...in debian 8 jessie i get an error with wx.Color call
        try:
            self.txReference.SetForegroundColour(wx.Color(255, 0, 0))
        except:
            pass

        self.stDescription = wx.StaticText(p, wx.ID_ANY, 'Description')
        self.txDescription = wx.TextCtrl(p,
                                         wx.ID_ANY,
                                         'No',
                                         size=(wx.GetApp().engine.get_font() *
                                               20, -1))

        self.stBill = wx.StaticText(p, wx.ID_ANY, 'Bill')
        self.txBill = masked.NumCtrl(p,
                                     wx.ID_ANY,
                                     integerWidth=4,
                                     fractionWidth=2,
                                     size=(wx.GetApp().engine.get_font() * 12,
                                           -1))
        self.txBill.SetToolTipString('Price.')

        self.stIssued = wx.StaticText(p, wx.ID_ANY, "Issued")
        self.dpcIssued = wx.DatePickerCtrl(
            p,
            size=(wx.GetApp().engine.get_font() * 12, -1),
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        self.dpcIssued.SetToolTipString('Issued date!')

        self.stExpiration = wx.StaticText(p, -1, "Expiration")
        self.dpcExpiration = wx.DatePickerCtrl(
            p,
            wx.ID_ANY,
            size=(wx.GetApp().engine.get_font() * 12, -1),
            style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        self.dpcExpiration.SetToolTipString('Expiration date!')

        self.stFlow = wx.StaticText(p, wx.ID_ANY, 'Flow')
        self.ckFlow = wx.CheckBox(p, wx.ID_ANY)
        self.ckFlow.SetToolTipString('Select = In\nDeselect = Out')

        self.stSettled = wx.StaticText(p, wx.ID_ANY, 'Settled')
        self.ckSettled = wx.CheckBox(p, wx.ID_ANY)
        self.ckSettled.SetToolTipString(
            'Select = settled\nDeselect = unsettle')

        self.stEnable = wx.StaticText(p, wx.ID_ANY, 'Enable')
        self.ckEnable = wx.CheckBox(p, wx.ID_ANY)

        sbb = wx.StaticBox(p, wx.ID_ANY, "")

        bts = [
            (wx.ID_SAVE, '&Save', 'save data!'),
            (wx.ID_CLOSE, '&Close', 'close frame'),
        ]
        for (id, label, help_text) in bts:
            b = wx.Button(
                p,
                id,
                label,
            )
            b.SetToolTipString(help_text)
            b.Bind(wx.EVT_BUTTON, self.OnClick)

        #sizers
        s0 = wx.BoxSizer(wx.HORIZONTAL)
        s1 = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        s2 = wx.StaticBoxSizer(sbb, wx.VERTICAL)

        w = (
            self.stSupplier,
            self.cbSuppliers,
            self.stCategory,
            self.cbCategories,
            self.stReference,
            self.txReference,
            self.stDescription,
            self.txDescription,
            self.stBill,
            self.txBill,
            self.stIssued,
            self.dpcIssued,
            self.stExpiration,
            self.dpcExpiration,
            self.stFlow,
            self.ckFlow,
            self.stSettled,
            self.ckSettled,
            self.stEnable,
            self.ckEnable,
        )
        for i in w:
            s1.Add(i, 0, wx.ALL, 1)

        for i in p.GetChildren():
            if type(i) in (wx.Button, ):
                s2.Add(i, 0, wx.EXPAND | wx.ALL, 5)

        w = (s1, s2)
        for i in w:
            s0.Add(i, 0, wx.ALL, 10)

        p.SetSizer(s0)
        s0.Fit(self)
        s0.SetSizeHints(self)
Ejemplo n.º 6
0
    def __init__(self,
                 parent=None,
                 id=wx.ID_ANY,
                 style=defStyle,
                 *args,
                 **kwargs):

        wx.Dialog.__init__(self, parent, id, *args, style=style, **kwargs)
        self.SetWindowStyle(wx.STAY_ON_TOP)  # this will be a modal dialog
        panel = wx.Panel(self, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
        self.parent = parent
        self.app = wx.GetApp()
        pavSession = pavlovia.getCurrentSession()
        if pavSession.user:
            pavSession.gitlab.auth()
            self.user = pavSession.user
        else:
            self.user = logInPavlovia(parent=parent)
            if not self.user:
                return  # they were given a login but cancelled
        if type(self.user) != pavlovia.User:
            self.user = pavlovia.User(gitlabData=self.user)

        # create the controls
        userField = wxhl.HyperLinkCtrl(panel,
                                       id=wx.ID_ANY,
                                       label=self.user.url,
                                       URL=self.user.url)
        logoutBtn = wx.Button(panel, label="Logout")
        logoutBtn.Bind(wx.EVT_BUTTON, self.onLogout)
        nameLabel = wx.StaticText(panel,
                                  id=wx.ID_ANY,
                                  label=_translate("Full name:"))
        self.nameField = wx.StaticText(panel, wx.ID_ANY, self.user.name)
        bitmapFile = self.user.avatar or "user_invisible.png"
        self.avatarBtn = self.app.iconCache.makeBitmapButton(
            parent=panel,
            filename=bitmapFile,
            label=self.user.name,
            name=self.user.name)

        org = self.user.organization or ""
        orgLabel = wx.StaticText(panel, wx.ID_ANY, _translate("Organization:"))
        self.orgField = wx.StaticText(panel, wx.ID_ANY, org, size=(300, -1))

        bio = self.user.bio or ""
        self.bioLabel = wx.StaticText(panel, wx.ID_ANY,
                                      _translate("Bio (250 chrs):"))
        self.bioField = wx.StaticText(panel,
                                      wx.ID_ANY,
                                      bio,
                                      style=wx.TE_MULTILINE)
        # submit/cancel
        buttonMsg = _translate("OK")
        updateBtn = wx.Button(panel, id=wx.ID_OK, label=buttonMsg)
        updateBtn.Bind(wx.EVT_BUTTON, self.submitChanges)
        # cancelBtn = wx.Button(panel, id=wx.ID_CANCEL, label=_translate("Cancel"))
        # cancelBtn.Bind(wx.EVT_BUTTON, self.onCancel)

        # layout
        userAndLogout = wx.BoxSizer(wx.VERTICAL)
        userAndLogout.Add(userField, 1, wx.ALL | wx.CENTER, 5)
        userAndLogout.Add(logoutBtn, 0, wx.ALL | wx.CENTER, 5)
        topRow = wx.BoxSizer(wx.HORIZONTAL)
        topRow.Add(userAndLogout, 1, wx.ALL | wx.CENTER, 5)
        topRow.Add(self.avatarBtn, 0, wx.ALL | wx.RIGHT, 5)

        fieldsSizer = wx.FlexGridSizer(cols=2, rows=5, vgap=10, hgap=10)
        fieldsSizer.AddMany([
            (nameLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
            (self.nameField, 0, wx.EXPAND),
            (orgLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
            (self.orgField, 0, wx.EXPAND),
            (self.bioLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
            (self.bioField, 1, wx.EXPAND),
        ])

        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(updateBtn)

        border = wx.BoxSizer(wx.VERTICAL)
        border.Add(topRow, 0, wx.ALL | wx.EXPAND, 5)
        border.Add(fieldsSizer, 1, wx.ALL | wx.EXPAND, 10)
        border.Add(btnSizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        panel.SetSizerAndFit(border)
        self.Fit()
Ejemplo n.º 7
0
 def Abort(self):
     """Abort the application"""
     # Try a nice shutdown first time through
     wx.CallLater(500, wx.GetApp().OnExit, 
                  wx.MenuEvent(wx.wxEVT_MENU_OPEN, ed_glob.ID_EXIT),
                  True)
Ejemplo n.º 8
0
def StartGame(gameroot, project, progress):

    global PROGRESS

    PROGRESS = progress
    PROGRESS_COUNTER = 0

    valid = (".py", ".cs")

    pdict = {}

    messageService = wx.GetApp().GetService(MessageService.MessageService)
    messageService.ShowWindow()

    view = messageService.GetView()
    if view:
        wx.GetApp().GetTopWindow().SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
        view.ClearLines()
        view.AddLines("Starting new game\n\n")

    STUFF = list(dirwalk('./starter.mmo'))

    assert 'starter.mmo' not in gameroot
    assert 'minions.of.mirth' not in gameroot
    #assert not os.path.exists(gameroot)

    pfiles = []
    for src in STUFF:
        dst = src.replace("starter.mmo", gameroot)

        try:
            os.makedirs(os.path.dirname(dst))
        except OSError:
            pass  # dir exists, ignore error
        if view:
            view.AddLines("copying %s\n" % src)
        shutil.copyfile(src, dst)

        PROGRESS.Update(PROGRESS_COUNTER, dst)
        PROGRESS_COUNTER += .25
        PROGRESS_COUNTER %= 100

        pfiles.append(dst)

    f = file("%s/packaging/content.py" % gameroot, "r")
    s = f.read()
    f.close()
    s = s.replace("starter.mmo", gameroot)

    f = file("%s/packaging/content.py" % gameroot, "w")
    f.write(s)
    f.close()

    project.AddFiles(["serverconfig/server.cfg"], "config")

    AddCoreModules(project)

    for dst in pfiles:
        dst = dst[2:]
        fname, ext = os.path.splitext(dst)
        if ext.lower() not in valid:
            continue

        base = os.path.dirname(dst)

        if not pdict.has_key(base):
            pdict[base] = []

        pdict[base].append(dst)

    pview = project.GetFirstView()

    if pview:
        pview._treeCtrl.Freeze()

    bases = pdict.keys()
    bases.sort()

    for base in bases:
        files = pdict[base]
        files.sort()
        project.AddFiles(files, base)
        PROGRESS.Update(PROGRESS_COUNTER, base)
        PROGRESS_COUNTER += 1
        PROGRESS_COUNTER %= 100

    if pview:
        try:
            pview._treeCtrl.CollapseAll()
        except:
            pass

        pview._treeCtrl.Thaw()

    SaveConfig(project)

    project.OnSaveDocument(project.GetFilename())

    if view:
        view.AddLines("\n\nNew game started.\n")
        wx.GetApp().GetTopWindow().SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
Ejemplo n.º 9
0

if __name__ == "__main__":
    app = wx.PySimpleApp()

    logging.basicConfig(level=logging.DEBUG)

    # Load a properties file if passed in args
    if len(sys.argv) > 1:
        propsFile = sys.argv[1]
        p.LoadFile(propsFile)
    else:
        if not p.show_load_dialog():
            print 'Plate Viewer requires a properties file.  Exiting.'
            # necessary in case other modal dialogs are up
            wx.GetApp().Exit()
            sys.exit()

#        p.LoadFile('../properties/2009_02_19_MijungKwon_Centrosomes.properties')
#        p.LoadFile('../properties/Gilliland_LeukemiaScreens_Validation.properties')

    pmb = PlateViewer(None)
    pmb.Show()

    app.MainLoop()

    #
    # Kill the Java VM
    #
    try:
        import javavbridge
Ejemplo n.º 10
0
print("   !!!  Welcome to Priithon !!!")
from Priithon.all import *


def _sebsDisplHook(v):
    if not v is None:  # != None:
        import __main__  #global _
        #_ = v
        __main__._ = v
        print(U.myStr(v))


import sys

sys.displayhook = _sebsDisplHook
#print "debug: Pr/includeAll"
#if sys.argv[1:]:
#    import string
#    print "start->eval:", sys.argv[1:]
#    eval(string.join(sys.argv[1:]))

#20051117-TODO: CHECK if good idea  U.naSetArrayPrintMode(precision=4, suppress_small=0)

import wx
if hasattr(sys, 'argv') and wx.GetApp(
) is not None:  # CHECK: in embedded wxPython sys,.argv not defined
    # sys.app not defined yet
    wx.GetApp().GetTopWindow().SetTitle("priithon on %s" % wx.GetHostName())
del wx
del sys
Ejemplo n.º 11
0
 def onExit(self, evt):
     wx.GetApp().ExitMainLoop()
Ejemplo n.º 12
0
def initialize():
    global mainFrame
    if mainFrame:
        raise RuntimeError("GUI already initialized")
    mainFrame = MainFrame()
    wx.GetApp().SetTopWindow(mainFrame)
Ejemplo n.º 13
0
 def OnUseNative(self, event):
     wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic",
                                   not event.IsChecked())
     wx.GetApp().GetTopWindow().LoadDemo("ListCtrl_virtual")
Ejemplo n.º 14
0
def currentLanguageIsRightToLeft():
    return wx.GetApp().GetLayoutDirection() == wx.Layout_RightToLeft
Ejemplo n.º 15
0
 def OnClose(self, event):
     """Handle frame closure event"""
     wx.GetApp().UnRegisterWindow(repr(self))
     event.Skip()