Exemplo n.º 1
0
 def onKeyUp(event):
     if not a.captured and hasattr(
             wx.GetActiveWindow(), 'menubar') and event.GetKeyCode(
             ) == wx.WXK_ALT and wx.GetActiveWindow().menubar.focus == None:
         wx.GetActiveWindow().menubar.AltFocus()
         a.captured = False
         return
     a.captured = False
     event.Skip()
Exemplo n.º 2
0
 def onKey(event):
     if hasattr(wx.GetActiveWindow(), 'menubar'):
         menubar = wx.GetActiveWindow().menubar
         if menubar.focus != None:
             a.captured = True
             if menubar.DoNaviCode(event.GetKeyCode()): return
         elif event.GetKeyCode() == wx.WXK_ALT:
             if not menubar.navimode: menubar.ToggleNaviMode(True)
             return
     event.Skip()
Exemplo n.º 3
0
Arquivo: lbc.py Projeto: njsch/PyLBC
def GetDefaultParent():
	app = None
	if not wx.GetApp(): app = App()
	parent = wx.GetActiveWindow()
	if not parent: parent = wx.FindWindowByName('desktop') # ctypes.windll.USER32.GetDesktopWindow()
	if app: app.Destroy()
	return parent
Exemplo n.º 4
0
    def askForChemistryDatabasePath(self):
        win = wx.GetActiveWindow()

        # try to guess a smart default dir
        cwd = os.getcwd()
        f = __file__
        d = os.path.dirname(__file__)
        p = cwd
        if d == cwd:  # means that current directory is certainly not choosen by the user
            # use the geoi project data directory
            p = os.path.split(d)[0]
            p = os.path.split(p)[0]
            p = os.path.join(p, "data")

        dlg = wx.DirDialog(win,
                           "Choose the Phreeqc Database directory:",
                           defaultPath=p,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.DD_CHANGE_DIR)

        path = None
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
        dlg.Destroy()
        return path
Exemplo n.º 5
0
 def _get_active_frame(self):
     win = wx.Window.FindFocus()
     return wx.GetTopLevelParent(win)
     for w in wx.GetTopLevelWindows():
         if hasattr(w, 'IsActive') and w.IsActive():
             return w
     return wx.GetActiveWindow()
Exemplo n.º 6
0
    def on_search_timer(self):
        active = wx.GetActiveWindow()
        focused = wx.Window.FindFocus()

        if active is None or not self.searching:
            self.stop_searching()

        if not hasattr(self, '_allowed_windows'):
            # active windows search will stick around for
            from gui.infobox.infobox import InfoBox
            from gui.buddylist.buddylistframe import BuddyListFrame
            from gui.searchgui import SearchEditDialog

            self._allowed_windows = frozenset(
                [InfoBox, BuddyListFrame, SearchEditDialog])
            self._empty_textfield_cancels = frozenset([BuddyListFrame])

        clz = active.__class__

        if clz not in self._allowed_windows:
            self.stop_searching()

        # if search loses focus to the buddylist and there is no text in the
        # search field, just cancel the search
        elif clz in self._empty_textfield_cancels and \
                focused is not self.TextField and \
                not self.TextField.Value:
            self.stop_searching()
Exemplo n.º 7
0
 def get_active_window(self):
     if hasattr(self.impl, "get_active_window"):
         return self.impl.get_active_window()
     else:
         win = wx.GetActiveWindow()
         if win:
             return win.Handle
         else:
             return -1
Exemplo n.º 8
0
def notImplementedYet():
    """
	shows a dialog that says that this feature its not implemented
	"""
    wx.GenericMessageDialog(parent=wx.GetActiveWindow(),
                            message=loc('popup.notimplemented.text'),
                            caption=loc('popup.notimplemented.title'),
                            style=wx.ICON_INFORMATION | wx.STAY_ON_TOP
                            | wx.OK).ShowModal()
Exemplo n.º 9
0
    def OnCardSet(self, event):
        if not hasattr(self, "cardset"):
            self.cardset = CardSetWin(wx.GetActiveWindow())

        self.cardset.CenterOnParent()

        if wx.ID_OK == self.cardset.ShowModal():
            self.selectedName = self.cardset.selectedName
            self.selectedMode = self.cardset.selectedMode
            self.filterBtn.Enable()
Exemplo n.º 10
0
def main(panel=None):

    q = wx.GetActiveWindow()
    p = wx.GetApp()
    #print(dir(p))
    #print(dir(q.m_mgr))
    p.ExitMainLoop()
    q.m_mgr.Unlink()
    #q.m_mgr.Unbind()
    q.m_mgr.Destroy()
Exemplo n.º 11
0
def main(panel=None):

    q = wx.GetActiveWindow()
    p = wx.GetApp()

    if str(q) == 'None':
        p.Exit()
        wx.App_CleanUp()
    else:
        q.Destroy()
        wx.App_CleanUp()
Exemplo n.º 12
0
def main(panel=None):

    q = wx.GetActiveWindow()
    p = wx.GetApp()

    if str(q) == 'None':
        p.Exit()
        wx.App_CleanUp()
    else:
        #print q.m_mgr
        q.m_mgr.UnInit()
        q.Destroy()
        wx.App_CleanUp()
Exemplo n.º 13
0
    def OnButton(self, evt):
        global FenHelp
        
        CloseFenHelp()
        
        w = 400
        ws, hs = wx.ClientDisplayRect()[2:]
        FenHelp = md_util.MDFrame(wx.GetActiveWindow(), self.titre, self.md, 
                                  pos = (ws-w, 0), size = (w, hs))
        FenHelp.SetIcon(GetIconHelp())
        FenHelp.Bind(wx.EVT_CLOSE, self.OnClose)
#        print self.titre
#        print FenHelp.GetBestHeight()
#        self.Fit()
#        print self.GetClientSize ()
        FenHelp.Show()
        FenHelp.Fit()
Exemplo n.º 14
0
def runMascotSearch(writeback = (lambda x: None)):
    if settings.mascot_security:
        dlg = LoginDialog(None)
        result = dlg.ShowModal()
        if result == wx.ID_OK:
            (login, password) = (dlg.FindWindowByName("Login").GetValue(),
                                 dlg.FindWindowByName("Password").GetValue())
        else:
            dlg.Destroy()
            return
        dlg.Destroy()
    else:
        (login, password) = ('', '')

    mascot_frame = MascotSearch(wx.GetActiveWindow(), login, password, writeback)

    mascot_icon_file = os.path.normpath(os.path.join(install_dir, 'images', 'icons', 'multiplierz.ico'))
    mascot_icon = wx.Icon(mascot_icon_file, wx.BITMAP_TYPE_ICO)
    mascot_frame.SetIcon(mascot_icon)

    mascot_frame.Show()
Exemplo n.º 15
0
def save_scene_as(sceneName=None, fileName=None):  #, parentWindow=None):
    """save_scene_as( sceneName=None, fileName=None)->Filename or False if fail 
    Save the current scene as a class in the scenes folder
        
sceneName: string with name to save as. If None, a dialog will be opened.
parentWindow: the parent window of name dialog. If not provided, the 
    wx.ActiveWindow will be used
"""
    wx.GetApp().apply()
    if get_scene_errors():
        return False
    if _DEBUG: print "util: save_scene_as"
    scene = PigDirector.scene
    if not sceneName:
        name = scene.__class__.__name__
        if name == 'Scene':
            name = 'MyScene'
        name = make_valid_attr_name(name)
        name.capitalize()
        if _DEBUG: print "util: save_scene_as 1"
        parentWindow = None
        if parentWindow == None:
            parentWindow = wx.GetActiveWindow()
        default = make_valid_attr_name(name)
        dlg = wx.TextEntryDialog(parentWindow,
                                 "Enter the scene's class/file name",
                                 "Save Scene", default)
        if _DEBUG: print "util: save_scene_as 2"
        while not sceneName:
            if dlg.ShowModal() == wx.ID_OK:
                name = dlg.GetValue()
                errorDlg = None
                if name == 'Scene':
                    errorDlg = wx.MessageDialog(
                        dlg, "You can't use the name 'Scene'", "Reserved Name",
                        wx.OK)
                elif name != make_valid_attr_name(name):
                    errorDlg = wx.MessageDialog( dlg,
                           "Name cannot contain spaces or special characters"+\
                           "\nand cannot start with a number",
                           "Invalid Name",
                           wx.OK)
                if errorDlg:
                    errorDlg.ShowModal()
                    errorDlg.Destroy()
                    dlg.SetValue(default)
                    dlg.SetFocus()
                    continue
                path = os.path.join('scenes', name + '.py')
                if name != scene.__class__.__name__:
                    try:
                        test = file(path)
                    except:
                        sceneName = name
                    else:
                        test.close()
                        confirmDlg = wx.MessageDialog(
                            dlg, "Scene file already exists. Overwrite?",
                            "Confirm Replace", wx.YES_NO | wx.NO_DEFAULT)
                        if confirmDlg.ShowModal() == wx.ID_YES:
                            if sys.platform == "win32":
                                files = os.listdir('scenes')
                                testname = name + '.py'
                                for f in files:
                                    if f.lower() == testname.lower():
                                        sceneName = os.path.splitext(f)[0]
                                        break
                            else:
                                sceneName = name
                        confirmDlg.Destroy()
                else:
                    sceneName = name
            else:
                dlg.Destroy()
                return False
        dlg.Destroy()
    else:
        if sceneName == 'Scene':
            raise ValueError("Can't save over baseclass 'Scene'")


#            save_scene_as( sceneName, fileName)
    if not fileName:
        fileName = ''.join([sceneName, '.py'])
    path = os.path.join('scenes', fileName)
    app = wx.GetApp()
    if _DEBUG: print "util: save_scene_as 4"
    selection = app.selectedObjectDict.keys()
    oldscene = PigDirector.scene
    from pig.editor.util import wait_for_state
    wait_for_state(None)
    if _DEBUG: print "util: save_scene_as 5"
    wx.GetApp().set_busy_state(True)
    saved = False
    try:
        if _DEBUG: print "util: save_scene_as enter code_exporter"
        code_exporter(scene, path, True, {'name': sceneName})
        if _DEBUG: print "util: save_scene_as exit code_exporter"
    except:
        if _DEBUG: print "util: save_scene_as 6"
        show_exception_dialog()
    else:
        if _DEBUG: print "util: save_scene_as 7"
        sceneDict = get_available_scenes(True)
        if '__Working__' not in path:
            PigDirector.scene.__class__ = sceneDict[sceneName]
        saved = True
        if _DEBUG: print "util: save_scene_as 8"
    finally:
        if _DEBUG: print "util: save_scene_as 9"
        wx.GetApp().set_busy_state(False)
        if PigDirector.scene != oldscene:
            wx.GetApp().set_selection([])
            if _DEBUG: print "util: save_scene_as reset select:", selection
        from pig.editor.EditorState import EditorState
        wait_for_state(EditorState)
        if _DEBUG: print "util: save_scene_as 10"
        wx.GetApp().refresh()
    if _DEBUG: print "util: save_scene_as 11"
    if saved:
        return fileName
    else:
        return False
Exemplo n.º 16
0
 def _error(self, title, msg):
     win = wx.GetActiveWindow()
     dlg = wx.MessageDialog(win, msg, title, wx.OK | wx.ICON_ERROR)
     dlg.ShowModal()
     dlg.Destroy()
Exemplo n.º 17
0
 def _info(self, title, msg):
     win = wx.GetActiveWindow()
     dlg = wx.MessageDialog(win, msg, title, wx.OK | wx.ICON_INFORMATION)
     dlg.ShowModal()
     dlg.Destroy()
Exemplo n.º 18
0
 def click_on_shape(self, event):
     if event.LeftIsDown() and event.Dragging() and wx.GetActiveWindow(
     ) == self.frame:
         self.frame.Move(wx.GetMousePosition()[0] - self.x_dif,
                         wx.GetMousePosition()[1] - self.y_dif)
     event.Skip()
Exemplo n.º 19
0
 def __init__(self):
     super(TemplateManagerWindow,
           self).__init__(parent=wx.GetActiveWindow(),
                          title='Manage Templates')
     self.Bind(wx.EVT_CLOSE, lambda evt: self.Show(False), self)
Exemplo n.º 20
0
 def clickNO():
     dlg = wx.GetActiveWindow()
     clickEvent = wx.CommandEvent(
         wx.wxEVT_COMMAND_BUTTON_CLICKED, wx.ID_NO)
     dlg.ProcessEvent(clickEvent)
Exemplo n.º 21
0
def save_object(obj, name=None, parentWindow=None):
    """save_object(obj): Export obj as a class to objects folder

name: the name to save the object as. If not provided, a dialog will be opened
parentWindow: the parent window of name dialog. If not provided, the 
    wx.ActiveWindow will be used
"""
    if not isinstance(obj, Node):
        raise TypeError('save_object() arg 1 must be a Node')
    if not name:
        if obj.archetype:
            name = obj.gname
        else:
            if obj.gname:
                name = obj.gname
            else:
                name = "MyClass"
        if not name:
            name = obj.__class__.__name__
        if parentWindow == None:
            parentWindow = wx.GetActiveWindow()
        objName = ''
        # we generally don't want to save with the same name as
        # a base class of the same object
        superclasses = getmro(obj.__class__)[1:]
        for cls in superclasses:
            if name == cls.__name__ or name == 'Sprite':
                name = ''.join(['My', name])
                break
        default = make_valid_attr_name(name)
        dlg = wx.TextEntryDialog(parentWindow,
                                 "Enter the object's class/file name",
                                 "Save Object", default)
        while not objName:
            if dlg.ShowModal() == wx.ID_OK:
                name = dlg.GetValue()
                errorDlg = None
                if name == 'Sprite':
                    errorDlg = wx.MessageDialog(
                        dlg, "You can't use the names 'Sprite'",
                        "Reserved Name", wx.OK)
                elif name != make_valid_attr_name(name):
                    errorDlg = wx.MessageDialog( dlg,
                           "Name cannot contain spaces or special characters"+\
                           "\nand cannot start with a number",
                           "Invalid Name",
                           wx.OK)
                if errorDlg:
                    errorDlg.ShowModal()
                    errorDlg.Destroy()
                    dlg.SetValue(default)
                    dlg.SetFocus()
                    continue
                path = os.path.join('objects', ''.join([name, '.py']))
                old_module = obj.__class__.__module__.split('.')
                if old_module[-2:-1][0] == 'objects' and \
                        old_module[-1:][0] != name:
                    # verify overwrite
                    try:
                        test = file(path)
                    except:
                        objName = name
                    else:
                        test.close()
                        confirmDlg = wx.MessageDialog(
                            dlg, "\n".join(
                                [path, "File already exists. Overwrite?"]),
                            "Confirm Replace", wx.YES_NO | wx.NO_DEFAULT)
                        if confirmDlg.ShowModal() == wx.ID_YES:
                            if sys.platform == "win32":
                                files = os.listdir('objects')
                                testname = name + '.py'
                                for f in files:
                                    if f.lower() == testname.lower():
                                        sceneName = os.path.splitext(f)[0]
                                        break
                            else:
                                objName = name
                        confirmDlg.Destroy()
                else:
                    objName = name
            else:
                dlg.Destroy()
                return
        dlg.Destroy()
    else:
        name = make_valid_attr_name(name)
        objName = name
        path = os.path.join('objects', ''.join([name, '.py']))
    try:
        if getattr(obj, 'archetype', False):
            # we don't want every instance to be an archetype
            obj.archetype = False
            archetype = True
        else:
            archetype = False
        from pig.Sprite import Sprite
        exporter = code_exporter(obj, path, True, {
            'name': objName,
            'base_class': Sprite
        })
        objDict = get_available_objects(True)
        oldclass = obj.__class__
        if oldclass != objDict[objName]:
            obj.__class__ = objDict[objName]
        if archetype:
            # return archetype status after saving
            obj.archetype = True
            obj.gname = objName
            if exporter.file_changed:
                archetype_changed(obj, oldclass, exporter)
        return exporter
    except:
        show_exception_dialog()
import wx
wx.GetActiveWindow()