コード例 #1
0
    def initWidgets(self, filters):

        dirMngr = self.dirMngr

        btnDirBack = self.btnDirBack = anygui.Button(text='<', size=(50, 25))
        if dirMngr.currDirIsRoot():
            btnDirBack.enabled = 0
        self.add(btnDirBack, left=10, top=10)
        link(btnDirBack, self.goDirBack)

        btnDirFwd = self.btnDirFwd = anygui.Button(text='>', size=(50, 25))
        btnDirFwd.enabled = 0
        self.add(btnDirFwd, left=(btnDirBack, 5), top=10)
        link(btnDirFwd, self.goDirFwd)

        frmDirs = self.frmDirs = anygui.Frame()
        frmDirs.layout = SimpleGridManager(3, 1)
        self.add(frmDirs, left=10, rigth=10, top=(btnDirBack, 5), \
                 bottom=75, vstretch=1, hstretch=1)

        lbxDirOne = self.lbxDirOne = anygui.ListBox()
        #lbxDirOne.items = self.dirList.tripane[0]
        lbxDirOne.items = self.dirMngr.currDirCache
        lbxDirOne.selection = 0
        frmDirs.add(lbxDirOne)
        link(lbxDirOne, self.lbxSelect)

        lbxDirTwo = self.lbxDirTwo = anygui.ListBox()
        frmDirs.add(lbxDirTwo)
        link(lbxDirTwo, self.lbxSelect)

        lbxDirThree = self.lbxDirThree = anygui.ListBox()
        frmDirs.add(lbxDirThree)
        link(lbxDirThree, self.lbxSelect)

        btnCancel = self.btnCancel = anygui.Button(text='Cancel')
        self.add(btnCancel, right=10, top=(frmDirs, 5), hmove=1, vmove=1)
        link(self.btnCancel, self.close)

        btnOpen = self.btnOpen = anygui.Button(text='Open')
        self.add(btnOpen, right=10, top=(btnCancel, 5), hmove=1, vmove=1)
        link(self.btnOpen, self.open)

        lblLocation = self.lblLocation = anygui.Label(text='Location:',
                                                      width=55)
        self.add(lblLocation, left=10, top=(frmDirs, 18), vmove=1)

        lblFilter = self.lblFilter = anygui.Label(text='Filter:', width=55)
        self.add(lblFilter, left=10, top=(lblLocation, 20), vmove=1)

        txtLocation = self.txtLocation = anygui.TextField(text=dirMngr.currDir)
        self.add(txtLocation, left=(lblLocation, 5), right=100, top=(frmDirs, 8), \
                 hstretch=1, vmove=1)
        link(txtLocation, self.changeDirs)

        cbxFilter = self.cbxFilter = anygui.ComboBox(items=filters)
        #txtFilter = self.txtFilter = TextField(text=dirMngr.filter)
        self.add(cbxFilter, left=(lblFilter, 5), right=100, top=(txtLocation, 10), \
                 hstretch=1, vmove=1)
        link(cbxFilter, self.applyFilter)
コード例 #2
0
ファイル: anygui1.py プロジェクト: BackupTheBerlios/lino-svn
    def build(self, win):

        self.filename = gui.TextField()
        win.add(self.filename, top=5, left=5, hstretch=1)

        self.prevButton = gui.Button(text='Prev <<', height=25)
        win.add(self.prevButton, left=(self.filename, 5), top=5, hmove=1)

        self.nextButton = gui.Button(text='>> Next', height=25)
        win.add(self.nextButton,
                left=(self.prevButton, 5),
                right=5,
                top=5,
                hmove=1)

        ##       grp = gui.RadioGroup(height=25)
        ##       self.rbn1 = gui.RadioButton(group=grp,text="A")
        ##       self.rbn2 = gui.RadioButton(group=grp,text="B")
        ##       self.rbn3 = gui.RadioButton(group=grp,text="C")
        ##       win.add((self.rbn1,self.rbn2,self.rbn3),
        ##               top=(self.contents,5),left=5,bottom=5,
        ##               direction='right',space=10)

        self.statusbar = gui.Label()
        win.add(
            self.statusbar,
            # top=(self.messages,5),
            bottom=5,
            left=5,
            right=5,  # height=10,
            vstrech=0,
            hstretch=1)

        self.messages = gui.Label()
        win.add(
            self.messages,
            # top=(self.contents,5),
            bottom=(self.statusbar, 5),
            left=5,
            right=5,  # height=20,
            vstrech=0,
            hstretch=1)

        self.contents = gui.TextArea()
        win.add(self.contents,
                top=(self.filename, 5),
                bottom=(self.messages, 5),
                left=5,
                right=5,
                hstretch=1,
                vstretch=1)

        # filename.text = "readme.txt"

        gui.link(self.nextButton, 'click', self.next)
        gui.link(self.prevButton, 'click', self.prev)
        console.notifier = self.notify
        self.read()
コード例 #3
0
 def initWidgets(self):
     #self.layout = SimpleGridManager(1,3)
     self.label = anygui.Label(text="Anygui info:")
     self.add(self.label, left=10, top=10)
     self.txtAbout = anygui.TextArea(text=ABOUT_TEXT, enabled=0)
     self.add(self.txtAbout, left=10, right=10, top=(self.label,5), \
              bottom=45, hstretch=1, vstretch=1)
     self.btnOK = anygui.Button(text="OK")
     self.add(self.btnOK, right=10, bottom=10, hmove=1, vmove=1)
     link(self.btnOK, self.close)
コード例 #4
0
def anygui_test(g= 'tkgui' ):
    '''http://anygui.sourceforge.net
    In [1]: from anygui import *
    In [2]: backend()
    Out[2]: 'msw'
    PythonWin  (mswgui)    {http://starship.python.net/crew/mhammond/win32}
    Tkinter    (tkgui)     {http://www.python.org/topics/tkinter}
    wxPython   (wxgui)     {http://www.wxpython.org}
    Java Swing (javagui)   {http://www.jython.org}
    PyGTK      (gtkgui)    {http://www.daa.com.au/~james/pygtk}
    Bethon     (beosgui)   {http://www.bebits.com/app/1564}
    PyQt       (qtgui)     {http://www.thekompany.com/projects/pykde}
    Curses     (cursesgui) -- used when no GUI package is available
    Plain text (textgui)   -- used if curses is not available
    'msw gtk java wx tk beos qt curses text'
: On some platforms, including FreeBSD and Mac OS X, setting environ may cause memory leaks. Refer to the system documentation for putenv
    {http://www.anygui.org}, subscribe to the developer's mailing list ([email protected]) and the user's list ([email protected]), and try to familiarise yourself with how the package works behind the scenes. 
        '''
    import os
    os.environ['ANYGUI_WISHLIST'] = 'tk wx * text curses' 

    #import anygui.backends.tkgui as gui
    import anygui as gui
    import rClickclass as rC

    app = gui.Application()

    btn = gui.Button(text= 'Hello' )
    lbx = gui.ListBox()
    lbx.items = 'first second third'.split() 
    TextA = gui.TextArea()

    win = gui.Window(size= (200,100) )
    win.add(btn, left= 0, top= 0, right= 0, bottom= 0, hstretch= 1, vstretch= 0 )
    win.add(lbx, hstretch= 1, vstretch= 0 )
    win.add(TextA, hstretch= 1, vstretch= 0 )

    app.add(win)

    u = rC.rClick(app._root, "anygui_test")
    app.run()
コード例 #5
0
 def _createWidgets(self):
     state = self.proxy.state
     x = state['x']
     y = state['y']
     width = state['width']
     height = state['height']
     self._lbxHeight = state['lbxHeight']
     items = list(self.proxy.items)
     self._textFld = anygui.TextField(geometry=(x, y, width - height,
                                                height))
     self._popupBtn = anygui.Button(text='v',
                                    geometry=(x + width - height, y, height,
                                              height))
     self._itemLbx = anygui.ListBox(
         visible=0,
         items=items,
         geometry=(
             x,
             y + height,  #this will be set later
             width,
             self._lbxHeight))
コード例 #6
0
ファイル: gui.py プロジェクト: hiddenman/impexp
    def _gui(self):
        # WORKAROUND
        self.auto=-1
        self.runmode=-1
        self.module=''

        # if (self.runmode==cfg.GUI_IMPORT):
        #    self.runmode=cfg.IMPORT
        # else:
        #     self.runmode=cfg.EXPORT

        def start_pressed(event):
            if (self.module==''):
                label_error.text='Hе выбран модуль для запуска'.decode(cfg.charset).encode(cfg.guicharset)
                label_error.visible=1
                return 0
            if (self.src_shop==None):
                label_error.text='Hе задан магазин-источник'.decode(cfg.charset).encode(cfg.guicharset)
                label_error.visible=1
                return 0
            if (self.dst_shop==None):
                label_error.text='Hе задан магазин назначения'.decode(cfg.charset).encode(cfg.guicharset)
                label_error.visible=1
                return 0                
            if (self.auto==-1):
                label_error.text='Hе задан режим запуска'.decode(cfg.charset).encode(cfg.guicharset)
                label_error.visible=1
                return 0
            if (self.runmode==-1):
                label_error.text='Hе задана операция'.decode(cfg.charset).encode(cfg.guicharset)
                label_error.visible=1
                return 0                
            self.dates=text_dates.text
            if (self.dates==''):
                label_error.text='Hе задана ни одна дата'.decode(cfg.charset).encode(cfg.guicharset)
                label_error.visible=1
                return 0
            label_error.text=''
            label_error.visible=0

            self.oldlogf=self.logf
            self.oldloglevel=self.loglevel
            self.oldrunmode=self.runmode
            self.oldupload=self.upload
            self.oldauto=self.auto
            self.oldargs=self.args
            self.oldsrc_shop=self.src_shop
            self.olddst_shop=self.dst_shop


            (modfile,modname,moddesc)=imp.find_module(self.module)
            module=imp.load_module(self.module,modfile,modname,moddesc)                
            # thread_=threading.Thread()
            name=self.module
            module_=eval('module.'+name+'()')
            
            if (self.runmode==cfg.IMPORT):
                self._log(log.INFO,"Запуск новой нити импорта модуля ["+str(module.__desc__)+"] из магазина "+str(self.src_shop)+' в магазин '+str(self.dst_shop)+', даты '+str(self.dates)+' с аргументами '+str(self.args)+'')                                
                newthread=thread.start_new_thread(module_.start_import,(self.auto,self.runmode,self.upload,self.src_shop,self.dst_shop,self.dates,self.loglevel,self.args))                                            
            else:
                self._log(log.INFO,"Запуск новой нити экспорта модуля ["+str(module.__desc__)+"] из магазина "+str(self.src_shop)+' в магазин '+str(self.dst_shop)+', даты '+str(self.dates)+' с аргументами '+str(self.args)+'')                                
                newthread=thread.start_new_thread(module_.start_export,(self.auto,self.runmode,self.upload,self.src_shop,self.dst_shop,self.dates,self.loglevel,self.args))
                
            self.logf=self.oldlogf
            self.loglevel=self.oldloglevel
            self.runmode=self.oldrunmode
            self.upload=self.oldupload
            self.auto=self.oldauto
            self.args=self.oldargs
                
        def exit_pressed(event):
            gui.remove(window_main)
            gui._running=0
            return 0

        def dates_entered(event):
            # BUG
            # Почему-то не работает этот хандлер ;-(
            self.dates=text_dates.text

        def module_selected(event):
            for module_ in self.modules_full:
                if (self.modules[list_modules.selection]==module_[__desc__]):
                    self.module=module_[__name__]
                    break
            
        def shop_from_selected(event):
            self.src_shop=[]
            self.src_shop.append(cfg.shops.items()[list_shops_from.selection][0])
            
        def shop_to_selected(event):
            self.dst_shop=[]            
            self.dst_shop.append(cfg.shops.items()[list_shops_to.selection][0])

        def auto_selected(event):
            self.auto=1
            
        def export_selected(event):
            self.runmode=cfg.EXPORT
            
        def import_selected(event):
            self.runmode=cfg.IMPORT


        def manual_selected(event):
            self.auto=0
            
        gui = anygui.Application()
        window_main = anygui.Window(text=(self.__desc__.decode(cfg.charset).encode(cfg.guicharset)))            
            
        button_start = anygui.Button(text='Старт'.decode(cfg.charset).encode(cfg.guicharset))
        button_exit = anygui.Button(text='Выход'.decode(cfg.charset).encode(cfg.guicharset))

        group_auto=anygui.RadioGroup()
        
        group_runmode=anygui.RadioGroup()        

        radio_auto=anygui.RadioButton(text='Автоматически'.decode(cfg.charset).encode(cfg.guicharset))
        radio_manual=anygui.RadioButton(text='Вручную'.decode(cfg.charset).encode(cfg.guicharset))

        radio_export=anygui.RadioButton(text='Экспорт'.decode(cfg.charset).encode(cfg.guicharset))
        radio_import=anygui.RadioButton(text='Импорт'.decode(cfg.charset).encode(cfg.guicharset))

        group_auto.add([radio_auto,radio_manual])
        group_auto.selection=1
        self.auto=1

        group_runmode.add([radio_export,radio_import])
        group_runmode.selection=1
        self.runmode=cfg.EXPORT


        text_dates=anygui.TextField()
        text_dates.text=date.get_cur_date(self.logf)

        label_dates=anygui.Label(text='Даты'.decode(cfg.charset).encode(cfg.guicharset))
        label_direction=anygui.Label(text='из                          в'.decode(cfg.charset).encode(cfg.guicharset))        
        label_error=anygui.Label(text=''.decode(cfg.charset).encode(cfg.guicharset))
        label_error.visible=0

        list_shops_from=anygui.ListBox(items=cfg.shops)
        list_shops_to=anygui.ListBox(items=cfg.shops)        

        self.load_modules()

        list_modules=anygui.ListBox(items=self.modules)
        
        # window_main.add(label_runmode,left=10,top=5,hmove=0)

        # Список модулей
        window_main.add(list_modules,left=10,top=10)
        # Hадпись 'из в'
        window_main.add(label_direction,left=(list_modules,50),top=10,hmove=0)

        # Списки магазинов 'из' и 'в'
        window_main.add((list_shops_from,list_shops_to),direction='right',left=(list_modules,10),top=(label_direction,5),space=10)
        list_shops_from.height=list_modules.height
        list_shops_to.height=list_modules.height
        
        # Радиокнопки 'Автоматически' и 'Вручную'
        window_main.add((radio_auto,radio_manual),direction='down',left=(list_shops_to,10),top=10)
        

        # Радиокнопки 'Экспорт' и 'Импорт'        
        window_main.add((radio_export,radio_import),direction='down',left=10,top=(list_modules,20))


        window_main.add(label_dates,left=(radio_export,50),top=(list_shops_from,5))
        
        window_main.add(text_dates,left=(radio_export,10),top=(label_dates,10),hstretch=1)
        text_dates.width=list_shops_from.width+list_shops_to.width+10
        
        ## text_dates.width=(list_shops_to.right-10)
        
        window_main.add(button_start,left=10,top=(text_dates,10))
        window_main.add(button_exit,left=(button_start,10),top=(text_dates,10))

        window_main.add(label_error,left=(button_exit,10),top=(text_dates,15))


        
        window_main.width=radio_manual.right+20
        label_error.width=window_main.width
        label_direction.width=window_main.width        
        window_main.height=(button_exit.bottom+10)
        # label_runmode.left=int((window_main.width-len(label_runmode.text)-50)/2)
        
        anygui.link(button_start,'click',start_pressed)
        anygui.link(button_exit,'click',exit_pressed)
        anygui.link(list_modules,'select',module_selected)        
        anygui.link(list_shops_from,'select',shop_from_selected)
        anygui.link(list_shops_to,'select',shop_to_selected)        
        anygui.link(text_dates,'enterkey',dates_entered)
        anygui.link(radio_auto,auto_selected)
        anygui.link(radio_manual,manual_selected)
        anygui.link(radio_export,export_selected)
        anygui.link(radio_import,import_selected)        

        gui.add(window_main)
        gui.run()

        return 1