Example #1
0
    def __init__(self, **kw):
        optiondefs = (
            ('padx',           1,                   Pmw.INITOPT),
            ('pady',           1,                   Pmw.INITOPT),
            ('framewidth',     1,                   Pmw.INITOPT),
            ('frameheight',    1,                   Pmw.INITOPT),
            ('usecommandarea', self.usecommandarea, Pmw.INITOPT))
        self.defineoptions(kw, optiondefs)
        
        self.root = Tk()
        self.initializeTk(self.root)
        Pmw.initialise(self.root)
        self.root.title(self.appname)
        self.root.geometry('%dx%d' % (self.frameWidth, self.frameHeight))

        # Initialize the base class
        Pmw.MegaWidget.__init__(self, parent=self.root)
        
        # initialize the application
        self.appInit()
        
        # create the interface
        self.__createInterface()
        
        # create a table to hold the cursors for
        # widgets which get changed when we go busy
        self.preBusyCursors = None
        
        # pack the container and set focus
        # to ourselves
        self._hull.pack(side=TOP, fill=BOTH, expand=YES)
        self.focus_set()

        # initialize our options
        self.initialiseoptions(AppShell)
Example #2
0
	def __init__(self, canvas):
		Pmw.initialise()
		self.balloon = Pmw.Balloon(canvas)
		self.canvas = canvas

		self.CANVAS_SIZE = 800
		
		# initiating variables to store images.
		self.scanner_image = PhotoImage(file='gui/images/WAP.gif')
		self.ap_image = PhotoImage(file='gui/images/ap2.gif')
		self.sta_image = PhotoImage(file='gui/images/sta.gif')
		
		# From Table2: Distance, average RSSI [dBm] and standard deviation for CC2420 ZigBee module:
		self.sig2dis = ([52,2],[53,4],[58,6],[63,9], [65,12], [70,15], [76,20], [82,25])
		self.ch2bg = ([1, 'green'], [2, 'blue'], [3, 'tan'], [4, 'gray'], [5, 'black'], [6, 'orange'], [7, 'pink'], [8, 'yellow'], [9, 'white'], [10, 'purple'], [11, 'red'])
		
		# Draw circular disc region around Scanner device
		self.draw_oval_gradient()
		self.aps_count = 0
		self.stas_count = 0
		
		# Put an icon of Scanner device on the center of circular disc.
		scanner = self.canvas.create_image(402,402, image=self.scanner_image, anchor=CENTER, tags='scanner')	
		# binding Pmw Balloon feature to 'scanner' item in canvas
		self.balloon.tagbind(self.canvas, scanner, 'Scanner device\nMAC Address:\nInterface used:\nSignal strength:')
Example #3
0
    def __init__(self):
        Frame.__init__(self)
        Pmw.initialise()
        self.pack(expand=YES, fill=BOTH)
        self.master.title("Optimum Loading of a Standard Container")

        # create scrolled text box
        self.cmd = Pmw.ScrolledText(
            self, text_width=120, text_height=20, text_wrap=WORD, hscrollmode="static", vscrollmode="static"
        )
        self.cmd.pack(side=BOTTOM, expand=YES, fill=BOTH, padx=5, pady=5)
        self.cmd.component("text").configure(background="black", foreground="green")

        menubar = Menu(self.master)  # top menu (horizontal)
        # sub menu (vertical)
        run_menu = Menu(menubar, tearoff=0)
        opt_menu = Menu(menubar, tearoff=0)
        # items of sub menu
        run_menu.add_command(label="Simulated Annealing", command=self.sa)
        run_menu.add_command(label="Taboo Search", command=self.ts)
        run_menu.add_command(label="Genetic Algorithm", command=self.ga)
        opt_menu.add_command(label="Load Dataset", command=self.ds)
        # link top menu and sub menu
        menubar.add_cascade(label="Run", menu=run_menu)
        menubar.add_cascade(label="Options", menu=opt_menu)
        # link main window and menu
        self.master["menu"] = menubar
Example #4
0
 def __init__(self, seq, parent=None):
     self.seq = seq
     self.parent = parent
     self.toplevel = Toplevel(parent)
     Pmw.initialise(parent)
     self.GetBlasts()
     self.Choices()
Example #5
0
    def __init__(self, parent):
        # Create and pack the SpecialEntry megawidgets.
        self._any = SpecialEntry(parent,
                labelpos = 'w',
                label_text = 'Text (max 10 chars):',
                validate = {'validator' : 'text', 'max' : 10},
                command = self.execute)
        self._any.setentry('abc')
        self._int = SpecialEntry(parent,
                labelpos = 'w',
                label_text = 'Int4:',
                validate = 'int4')
        self._int.setentry(1)
        self._real = SpecialEntry(parent,
                labelpos = 'w',
                label_text = 'Real (max 2,5e+9):',
                validate = {'validator' : 'real', 'max' : +2.5e+9},
                )
        self._real.setentry('+2.5e+6')
        self._date = SpecialEntry(parent,
                labelpos = 'w',
                label_text = 'Date (dd.mm.yy):',
                validate = 'date',
                modifiedcommand = self.changed
                )
        # Set entry to one week from now, using special intput format.
        self._date.setentry('+7+')

        entries = (self._any, self._int, self._real, self._date)

        for entry in entries:
            entry.pack(fill='x', expand=1, padx=10, pady=5)
        Pmw.alignlabels(entries)

        self._any.component('entry').focus_set()
    def __init__(self, parent = None, **kw):
	# Define the megawidget options.
	optiondefs = (
	    ('filter',    '*',              self.newfilter),
	    ('directory', os.getcwd(),      self.newdir),
	    ('filename',  '',               self.newfilename),
	    ('historylen',10,               None),
	    ('command',   None,             None),
            ('info',      None,             None),
	    )
	self.defineoptions(kw, optiondefs)
        # Initialise base class (after defining options).
	Pmw.Dialog.__init__(self, parent)

	self.withdraw()

        # Create the components.
	interior = self.interior()

        if self['info'] is not None:
            rowoffset=1
            dn = self.infotxt()
            dn.grid(row=0,column=0,columnspan=2,padx=3,pady=3)
        else:
            rowoffset=0

	dn = self.mkdn()
	dn.grid(row=0+rowoffset,column=0,columnspan=2,padx=3,pady=3)
	del dn

	# Create the directory list component.
	dnb = self.mkdnb()
	dnb.grid(row=1+rowoffset,column=0,sticky='news',padx=3,pady=3)
	del dnb

	# Create the filename list component.
	fnb = self.mkfnb()
	fnb.grid(row=1+rowoffset,column=1,sticky='news',padx=3,pady=3)
	del fnb

	# Create the filter entry
	ft = self.mkft()
	ft.grid(row=2+rowoffset,column=0,columnspan=2,padx=3,pady=3)
	del ft

	# Create the filename entry
	fn = self.mkfn()
	fn.grid(row=3+rowoffset,column=0,columnspan=2,padx=3,pady=3)
	fn.bind('<Return>',self.okbutton)
	del fn

	# Buttonbox already exists
	bb=self.component('buttonbox')
	bb.add('OK',command=self.okbutton)
	bb.add('Cancel',command=self.cancelbutton)
	del bb

	Pmw.alignlabels([self.component('filename'),
			 self.component('filter'),
			 self.component('dirname')])
Example #7
0
	def __init__( self ):
		"""QueryWindow Constructor"""

		Frame.__init__( self )
		Pmw.initialise()
		self.pack( expand = YES, fill = BOTH )
		self.master.title( \
			"Enter Query, Click Submit to See Results." )
		self.master.geometry( "525x525" )

		# scrolled text pane for query string
		self.query = Pmw.ScrolledText( self, text_height = 8 )
		self.query.pack( fill = X )

		# button to submit query
		self.submit = Button( self, text = "Submit query",
			command = self.submitQuery )
		self.submit.pack( fill = X )

		# frame to display query results
		self.frame = Pmw.ScrolledFrame( self,
			hscrollmode = "static", vscrollmode = "static" )
		self.frame.pack( expand = YES, fill = BOTH )

		self.panes = Pmw.PanedWidget( self.frame.interior(),
			orient = "horizontal" )
		self.panes.pack( expand = YES, fill = BOTH )
Example #8
0
 def __init__ (self, parent, template_editor, v, members):
     Pmw.Group.__init__ (self, parent,
                         tag_text = attribute_labels.get(v.member, v.member)
                         )
     gui_support.balloon.bind(self.component('tag'),
                              attribute_explanations.get(v.member, v.member)
                              )
     self.template_editor = template_editor
     self.template_attribute = v
     self.members = ['priority'] + members
     self.canvas = template_editor.canvas
     self.entries = {}
     self.attribute_name = v.member
     f = self.interior()
     r = 0
     for itemname in self.members:
         if entry_editors.has_key(itemname):
             e = entry_editors[itemname](self.interior(), itemname, self)
         else:
             print  'Template editor internal error, missed', itemname
         e.pack(side='top', expand=1, fill='x')
         self.entries[itemname] = e
         r += 1
     Pmw.alignlabels(self.entries.values())
     self.priority_check()
Example #9
0
    def __init__(self, master):
	now = time.localtime(time.time())
	self._date = Pmw.EntryField(master,
		labelpos = 'w',	label_text = 'Date (mm/dd/yy):',
		value = '%d/%d/%d' % (now[1], now[2], now[0]),
		validate = {'validator':'date',
			    'format':'mdy', 'separator':'/'})
	self._time = Pmw.EntryField(master,
		labelpos = 'w',	label_text = 'Time (24hr clock):',
		value = '8:00:00',
		validate = {'validator':'time',
			    'min':'00:00:00', 'max':'23:59:59',
			    'minstrict':0, 'maxstrict':0})
	self._real = Pmw.EntryField(master,
		labelpos = 'w',	value = '127.2',
		label_text = 'Real (50.0 to 1099.0):',
		validate = {'validator':'real',
                            'min':50, 'max':1099,
                            'minstrict':0},
                modifiedcommand = self.valueChanged)
        self._ssn = Pmw.EntryField(master,
		labelpos = 'w', label_text = 'Social Security #:',
		validate = self.validateSSN, value = '')
        
	fields = (self._date, self._time, self._real, self._ssn)

	for field in fields:
	    field.pack(fill='x', expand=1, padx=12, pady=8)
	Pmw.alignlabels(fields)

	self._date.component('entry').focus_set()
    def _postList(self, event = None):
        self._isPosted = 1
        self._drawArrow(sunken=1)

        # Make sure that the arrow is displayed sunken.
        self.update_idletasks()

        x = self._entryfield.winfo_rootx()
        y = self._entryfield.winfo_rooty() + \
            self._entryfield.winfo_height()
        w = self._entryfield.winfo_width() + self._arrowBtn.winfo_width()
        h =  self.__listbox.winfo_height()
        sh = self.winfo_screenheight()

        if y + h > sh and y > sh / 2:
            y = self._entryfield.winfo_rooty() - h

        self._list.configure(hull_width=w)

        Pmw.setgeometryanddeiconify(self._popup, '+%d+%d' % (x, y))

        # Grab the popup, so that all events are delivered to it, and
        # set focus to the listbox, to make keyboard navigation
        # easier.
        Pmw.pushgrab(self._popup, 1, self._unpostList)
        self.__listbox.focus_set()

        self._drawArrow()

        # Ignore the first release of the mouse button after posting the
        # dropdown list, unless the mouse enters the dropdown list.
        self._ignoreRelease = 1
    def __init__(self, app):
        self.parent = app.root
        self.dialog = Pmw.Dialog(self.parent,
                                 buttons=('Ray', 'Draw', 'Exit'),
                                 title = 'PyMOL Rendering Plugin',
                                 command = self.execute)
        self.dialog.withdraw()
        Pmw.setbusycursorattributes(self.dialog.component('hull'))

        w = Tkinter.Label(self.dialog.interior(),
                          text='PyMOL Rendering Plugin\nMichael Lerner, 2006 - www.umich.edu/~mlerner/PyMOL\nNOTE: make sure this window is not on top of the PyMOL window.',
                          background='black',
                          foreground='white',
                          )
        w.pack(expand=1, fill='both', padx=4, pady=4)

        #self.notebook = Pmw.NoteBook(self.dialog.interior())
        # self.notebook.pack(fill='both',expand=1,padx=10,pady=10)

        # Set up the Main page
        #page = self.notebook.add('Main')
        #group = Pmw.Group(page,tag_text='Main options')

        group = Pmw.Group(self.dialog.interior())

        group.pack(fill='both', expand=1, padx=10, pady=5)
        self.filename = Pmw.EntryField(group.interior(),
                                       labelpos='w',
                                       label_text='Filename',
                                       value='picture.png',
                                       )
        self.height = Pmw.EntryField(group.interior(), labelpos='w',
                                     label_text='Height:',
                                     value=str(4.0),
                                     validate={'validator': 'real',
                                                 'min': 0, }
                                     )

        self.width = Pmw.EntryField(group.interior(), labelpos='w',
                                    label_text='Width:',
                                    value=str(4.0),
                                    validate={'validator': 'real',
                                                'min': 0, }
                                    )
        self.units = Pmw.OptionMenu(group.interior(), labelpos='w',
                                    label_text='Units',
                                    items=('inch', 'cm',),
                                    )
        self.dpi = Pmw.EntryField(group.interior(), labelpos='w',
                                  label_text='DPI:',
                                  value=str(300),
                                  validate={'validator': 'real',
                                              'min': 0, }
                                  )
        entries = (self.height, self.width, self.units, self.filename, self.dpi)
        for entry in entries:
            # entry.pack(side='left',fill='both',expand=1,padx=4) # side-by-side
            entry.pack(fill='x', expand=1, padx=4, pady=1)  # vertical
        # self.notebook.setnaturalsize()
        self.showAppModal()
Example #12
0
	def setUpWidgets(self):
                #Top widgets
                #self.headerFrame = Frame(self.root, width=WIDTH)
                #self.headerFrame.grid(row=0,column=0,columnspan=2)
                #headerImage = Image.open(self.appDirectory + '\\images\\header.png')
                #headerPhoto = ImageTk.PhotoImage(headerImage)
                #self.headerLabel = Label(self.headerFrame,image=headerPhoto,width=WIDTH,height=65,bg='orange')
                #self.headerLabel.image = headerPhoto
                #self.headerLabel.pack()
                #End top widgets

                #Sound widgets
		Pmw.initialise(self.root)
                #Pmw.Color.setscheme(self.root,background='#EEEEEE')

		self.soundsFrame = Frame(self.root, width=SOUNDFRAMEWIDTH,height=SOUNDFRAMEHEIGHT,background='#EEEEEE')
		self.soundsFrame.grid(row=1,column=0)

                self.gender = BooleanVar()

                #For the radiobutton, True = male, False = female
                self.maleRadioButton = Radiobutton(self.soundsFrame,text='Male',variable=self.gender,value=True,command=self.updateGenderAffectedFunctions)
                self.maleRadioButton.grid(row=0,column=0,columnspan=2,sticky='w',padx=15)
                self.femaleRadioButton = Radiobutton(self.soundsFrame,text='Female',variable=self.gender,value=False,command=self.updateGenderAffectedFunctions)
                self.femaleRadioButton.grid(row=1,column=0,columnspan=2,sticky='w',padx=15)
                self.maleRadioButton.select()
                

		#End of sound widgets

                #Formant Plot widgets
		self.mainFrame = Frame(self.root, width=FORMANTPLOTFRAMEWIDTH, height=FORMANTPLOTFRAMEHEIGHT,background='#EEEEEE')
		self.mainFrame.grid(row=1,column=1)
		
		self.tabbedPane = Pmw.NoteBook(self.mainFrame)
		

		self.tabbedPane.pack(fill='both')
		self.formantTab = self.tabbedPane.add('Formant Plot')
		#self.pronunciationTab = self.tabbedPane.add('Pronunciation Aid')		

                self.formantPlot = FormantPlot(self.formantTab, self.appDirectory,self.root,self.getGender())
		
		#End of Formant Plot widgets

		#Pronunciation Plot widgets

		#self.pronunciationAid = PronunciationAid(self.pronunciationTab,self.appDirectory,self.root)

		#End Pronunciation Plot widgets
                self.tabbedPane.setnaturalsize()

                
		
		
		
		#self.frame = Frame(self.root)
		#self.frame.grid(row=1,column=0)
		
		'''
Example #13
0
    def __init__(self, parent):
        # Create and pack the OptionMenu megawidgets.
        # The first one has a textvariable.
        self.var = tkinter.StringVar()
        self.var.set('steamed')
        self.method_menu = Pmw.OptionMenu(parent,
                labelpos = 'w',
                label_text = 'Choose method:',
                menubutton_textvariable = self.var,
                items = ['baked', 'steamed', 'stir fried', 'boiled', 'raw'],
                menubutton_width = 10,
        )
        self.method_menu.pack(anchor = 'w', padx = 10, pady = 10)

        self.vege_menu = Pmw.OptionMenu (parent,
                labelpos = 'w',
                label_text = 'Choose vegetable:',
                items = ('broccoli', 'peas', 'carrots', 'pumpkin'),
                menubutton_width = 10,
                command = self._printOrder,
        )
        self.vege_menu.pack(anchor = 'w', padx = 10, pady = 10)

        self.direction_menu = Pmw.OptionMenu (parent,
                labelpos = 'w',
                label_text = 'Menu direction:',
                items = ('flush', 'above', 'below', 'left', 'right'),
                menubutton_width = 10,
                command = self._changeDirection,
        )
        self.direction_menu.pack(anchor = 'w', padx = 10, pady = 10)

        menus = (self.method_menu, self.vege_menu, self.direction_menu)
        Pmw.alignlabels(menus)
Example #14
0
def main():
    root = tkinter.Tk()
    root.option_readfile('.picknames2.tkinter.options')
    root.wm_title('取名字')
    Pmw.initialise()
    app = App(root)
    root.mainloop()
	def fillInUI(self, parent):
		import Tkinter, Pmw
		from chimera.initprefs import ksdsspPrefs, KSDSSP_ENERGY, \
				KSDSSP_HELIX_LENGTH, KSDSSP_STRAND_LENGTH

		self.fields= []
		self.energyField = Pmw.EntryField(parent, labelpos='w',
			label_text='H-bond energy cutoff (kcal/mol):',
			validate='real', value=str(ksdsspPrefs[KSDSSP_ENERGY]))
		self.fields.append(self.energyField)

		self.helixField = Pmw.EntryField(parent, labelpos='w',
				label_text='Minimum helix length:',
				validate='numeric',
				value=str(ksdsspPrefs[KSDSSP_HELIX_LENGTH]))
		self.fields.append(self.helixField)

		self.strandField = Pmw.EntryField(parent, labelpos='w',
				label_text='Minimum strand length:',
				validate='numeric',
				value=str(ksdsspPrefs[KSDSSP_STRAND_LENGTH]))
		self.fields.append(self.strandField)

		for i in range(len(self.fields)):
			self.fields[i].grid(row=i, column=0)
		Pmw.alignlabels(self.fields, sticky='e')
Example #16
0
def panimage(ima,columns=5):
    "panimage(ima) - display ima in a scrolled window"
    top = Tkinter.Toplevel()
    top.title('panimage ')
    Pmw.initialise()
    sf = Pmw.ScrolledFrame(top, labelpos=N, label_text='Image Array',
                usehullsize=1, hull_width=700, hull_height=420)
    sf.pack(fill='both',expand=1)
    frame=[]
    image=[]
    numb=[]
    vminl=[]
    vmaxl=[]
    nd = len(ima)
    h = len(ima[0])
    w = len(ima[0][0])
    pal = readPalette()
    for i in range(nd):
	im = array(ima[i])
	vmin,vmax = max(max(im)),min(min(im))
        da = preprocess(im)
        frame.append(Tkinter.Frame(sf.interior()))
	image.append(PNGImage2(frame[i], da ,pal=pal,tmpNm='tmp.ppm'))
        image[i].pack(side='top')
	dn = 'Image Array : Seq # '+str(i) +': '
        numb.append(Tkinter.Label(frame[i], text=dn) )
        numb[i].pack(side='top')
	vminl.append(Tkinter.Label(frame[i],text='min:'+str(vmin)))
        vminl[i].pack(side='top')
	vmaxl.append(Tkinter.Label(frame[i],text='max:'+str(vmax)))
        vmaxl[i].pack(side='top')
        frame[i].grid(row=i/columns,column=i%columns, padx=0,pady=5)
Example #17
0
    def root(self):
        if self._root is None:
            from pymol.Qt import QtCore

            tkinter_init()

            # create Tk instance in this thread
            self._root = tkinter.Tk()
            self._root.tk = tkapp_proxy(self._root.tk, self)
            self._root.withdraw()

            # feed Tk event loop from this thread
            timer = QtCore.QTimer()
            @timer.timeout.connect
            def _():
                if not self._tk_update_paused:
                    self._root.update()
                timer.start()
            timer.setSingleShot(True)
            timer.start(50)

            # keep reference to timer
            self._tk_update_timer = timer

            import Pmw
            Pmw.initialise(self._root)

        return self._root
Example #18
0
 def __init__(self, master=None):
     Tk.__init__(self, master)
     Pmw.initialise(self)
     self.title("Ubernetx0r")
     self.makeWidgets()
     
     self.connection = ConnectionWrapper(self)
Example #19
0
    def __init__(self):
        """Create two ScrolledText and a Button"""

        Frame.__init__(self)
        Pmw.initialise()
        self.pack(expand=YES, fill=BOTH)
        self.master.title("ScrolledText Demo")

        # create scrolled text box with word wrap enable
        self.text1 = Pmw.ScrolledText(
            self, text_width=25, text_height=12, text_wrap=WORD, hscrollmode="static", vscrollmode="static"
        )
        self.text1.pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=5)

        self.copyButton = Button(self, text="Copy >>>", command=self.copyText)
        self.copyButton.pack(side=LEFT, padx=5, pady=5)

        # create uneditable scrolled text box
        self.text2 = Pmw.ScrolledText(
            self,
            text_state=DISABLED,
            text_width=25,
            text_height=12,
            text_wrap=WORD,
            hscrollmode="static",
            vscrollmode="static",
        )
        self.text2.pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=5)
Example #20
0
	def __init__(self, parent, text, **kw):
		self._replacepattern = '?'
                self._history = []
		self._text = text
		optiondefs = ()
        	self.defineoptions(kw, optiondefs)
		Pmw.Dialog.__init__(self, parent)
		self.withdraw()

		self.configure(buttons=('Close',), defaultbutton=0)

		interior = self.interior()

        	self.__findentry = Pmw.EntryField(interior, labelpos='w',
			label_text='Find what:', validate=None)
        	self.__replaceentry = Pmw.EntryField(interior, labelpos='w',
			label_text='Replace by:', validate=None)
		entries = (self.__findentry, self.__replaceentry)
		for entry in entries:
			entry.pack(side='top', fill='x', expand='no', 
				padx=5, pady=5)
		Pmw.alignlabels(entries)

		self.__buttonbox = Pmw.ButtonBox(interior, padx=0, pady=0)
		self.__buttonbox.add('Find', command=self.__find)
		self.__buttonbox.add('Replace', command=self.__replace)
		self.__buttonbox.add('Replace All', command=self.__replaceAll)
		self.__buttonbox.add('Undo', command=self.__undo)
		self.__buttonbox.pack(side=TOP, expand=NO, fill=X)
		self.__buttonbox.alignbuttons()

		self.initialiseoptions(Dialog)
Example #21
0
    def savePolygon(self):
        #print "saving polygon " + self.selectedPolygon
        if self.selectedPolygon == "":
            print "no polygon selected"
            return
        pobj = self.Polygons[self.selectedPolygon]
        screencoords = self.getPixelCoords(pobj.coords)
        polyname = self.selectedPolygon
       
        # get PIL image of datapoints, polygon
        Pmw.showbusycursor()
        im, imsk = self.mkDataMasks(polyname, pobj.coords)
        
        im = im.convert("1")       # binarize the images
        imsk = imsk.convert("1")

        res = ImageChops.multiply(im,imsk)  

        rp = self.getpixels(res)   # rp = list of pixels found in image
        fk = self.findPixelsInList(rp)  # fk = list of matched elements

        # add the found elements to the Polygon instance
        pobj.elements = fk
        self.Polygons[self.selectedPolygon] = pobj
        self.selectedPolyMarkers()  # colors the selected markers

        self.saveSelectedMarkers()

        del(im, imsk, res)  # does this speed up or slow down next call?
        Pmw.hidebusycursor()
Example #22
0
 def about(self):
    """ Opens a display window with information about the application. """
    Pmw.aboutversion('Version 1.0\nMay 10, 2002')
    Pmw.aboutcontact('Mark Rivers\n' +
                     'The University of Chicago\n' +
                     '[email protected]\n')
    t = Pmw.AboutDialog(self.top, applicationname='epicsLogger')
Example #23
0
	def __init__(self,master):
		Pmw.MegaToplevel.__init__(self,master)
		self.master = master
		self.user =None
#		self.master = master		
#		########################################################
#		#标题栏
#		frmtitle =Frame(self)
#		frmtitle.pack(side='top')
#		
#		########################################################3
		tp = self.component('hull')
		tp.title(unicode('登录密码修改'))
		f = Frame(tp)
		f.pack(fill='x',side='bottom',expand=1,padx=10,pady=4)
		self.usr = Pmw.EntryField(f,labelpos = 'w',label_text=unicode('当前登录用户:'),validate={'max':20})
		self.usr.pack(pady=2)
		self.oldpsw = Pmw.EntryField(f,labelpos = 'w',label_text=unicode('旧密码:'),validate={'max':20})
		self.oldpsw.pack(pady=2)
		self.oldpsw.component('entry').config(show='*')
		self.newpsw = Pmw.EntryField(f,labelpos = 'w',label_text=unicode('新密码:'),validate={'max':20})
		self.newpsw.pack(pady=2)
		self.newpsw.component('entry').config(show='*')
		self.newpsw2 = Pmw.EntryField(f,labelpos = 'w',label_text=unicode('确认新密码:'),validate={'max':20})
		self.newpsw2.pack(pady=2)
		self.newpsw2.component('entry').config(show='*')
		Pmw.alignlabels((self.usr,self.oldpsw,self.newpsw,self.newpsw2))
		
		f = Frame(f)
		f.pack(pady=10)
		Button(f,text=unicode('关闭'),command=lambda :self.destroy()).pack(side='right',padx=4)
		Button(f,text=unicode('修改'),command=self.save).pack(side='right',padx=4)
Example #24
0
    def __init__(self, parent, viewers, **kw):
        Pmw.Dialog.__init__(self, parent, **kw)
        self.withdraw()
        self.title(Avn.Name + ' Time Selector')

        self._ident = None
        self._sites = None

        self.configure(buttons=('Reset', 'Close'),
            defaultbutton='Close',
            command=self.__execute,
            )

        self.viewers = [v for v in viewers if v.tag != 'metar']

        f = Frame(self.interior())
        self.combo = {}
        for v in self.viewers:
            self.combo[v.tag] = Pmw.ComboBox(f,
                label_text=v.label,
                labelpos='w',
                entry_width=22,
            )
            self.combo[v.tag].pack(side='top', padx=5)
        Pmw.alignlabels(self.combo.values())
        f.pack(side='top')
Example #25
0
    def show_pmw_dialog(self):
        """Show a pmw dialog window"""
        import Pmw
        # Create the dialog.
        self.dialog = Pmw.Dialog(self.main,
            buttons = ('OK', 'Apply', 'Cancel', 'Help'),
            defaultbutton = 'OK',
            title = 'My dialog')
            #command = self.execute)
        self.dialog.withdraw()

        # Add some contents to the dialog.
        w = Label(self.dialog.interior(),
            #text = self.themessage,
            text='Working',
            background = 'black',
            foreground = 'white',
            pady = 20)
        w.pack(expand = 1, fill = 'both', padx = 4, pady = 4)

        # Create the window excluded from showbusycursor.
        self.excluded = Pmw.MessageDialog(self.main,
            title = 'I still work',
            message_text =
                'This window will not get\n' +
                'a busy cursor when modal dialogs\n' +
                'are activated.  In addition,\n' +
                'you can still interact with\n' +
                'this window when a "no grab"\n' +
                'modal dialog is displayed.')
        self.excluded.withdraw()
        Pmw.setbusycursorattributes(self.excluded.component('hull'),
            exclude = 1)
        return
Example #26
0
    def CreateReleasePage (self):
        "Create the page for editing the top level release information."
        # Create the page.
        self.releasePage = Pmw.LabeledWidget (self.pageFrame,
                    labelpos = 'n',
                    label_text = "\n\nRelease Information",
                    labelmargin = 10)

        # Create a frame for holding the entries.
        interiorFrame = Tkinter.Frame (self.releasePage.interior())

        # Create an entry for the release name.
        self.releaseNameEntry = Pmw.EntryField(interiorFrame,
                labelpos = 'w',
                label_text = 'Name:',
                validate = None,
                modifiedcommand = self.ReleaseNameChanged)

        # Create an entry for the output directory.
        self.outputDirEntry = Pmw.EntryField(interiorFrame,
                labelpos = 'w',
                label_text = 'Output Directory:',
                validate = None,
                modifiedcommand = self.OutputDirChanged)

        # Arrange the widgets on the page.
        interiorFrame.pack(expand=1, fill='x', padx=40, anchor='center')
        entries = (self.releaseNameEntry,  self.outputDirEntry)
        for entry in entries:
            entry.pack(fill='x', expand=1, pady=20)
        Pmw.alignlabels(entries)
Example #27
0
    def CreateSSProjectPage (self):
        "Create the page for editing the Source Safe project information."
        # Create the page.
        self.ssProjectPage = Pmw.LabeledWidget (self.pageFrame,
                    labelpos = 'n',
                    label_text = "\n\nSource Safe Project Information",
                    labelmargin = 10)
        interiorFrame = Tkinter.Frame(self.ssProjectPage.interior())

        # Create an entry for the release name.
        self.ssProjectNameEntry = Pmw.EntryField(interiorFrame,
                labelpos = 'w',
                label_text = 'Path:',
                validate = None,
                modifiedcommand = self.SSPathChanged)

        # Create an entry for the output directory.
        self.ssProjectVersionEntry = Pmw.EntryField(interiorFrame,
                labelpos = 'w',
                label_text = 'Version:',
                validate = None,
                modifiedcommand = self.SSVersionChanged)

        # Arrange the widgets on the page.
        interiorFrame.pack(expand=1, fill='x', anchor='center', padx=100)
        entries = (self.ssProjectNameEntry,  self.ssProjectVersionEntry)
        for entry in entries:
            entry.pack(fill='x', expand=1, pady=20)
        Pmw.alignlabels(entries)
Example #28
0
 def file_or_import(self,parent,result):
    if self.mode != result:
        self.eny5_file.clear()
        self.eny5_import.clear()
        self.eny6.clear()
        self.eny7.clear()
        # Set mode of function aquisition
        self.mode = result
        if result == 'Import':
            self.group2a.component('tag').configure(text = 'Add function to menu from import module')
            self.eny5_file.pack_forget()
            self.eny5_import.pack(side = 'left', before = self.btn4, fill = 'x',expand = 1, padx = 10)
            labels = (self.eny5_import, self.eny6, self.eny7)
            Pmw.alignlabels(labels)
            self.eny5_import.component('label').component('menubutton').configure(text = 'Import')
            self.btn4.configure(state = 'disabled')
            self.import_functions()
        else:
            self.group2a.component('tag').configure(text = 'Add function to menu from file')
            self.eny5_import.pack_forget()
            self.eny5_file.pack(side = 'left', before = self.btn4, fill = 'x',expand = 1, padx = 10)
            labels = (self.eny5_import, self.eny6, self.eny7)
            Pmw.alignlabels(labels)
            self.eny5_file.component('label').component('menubutton').configure(text = 'File')
            self.btn4.configure(state = 'normal')
Example #29
0
def PMW_test():  #http://download.sourceforge.net/pmw
    '''parts stolen from Tkinter list
    '''
    import Tkinter as Tk
    import Pmw
    import rClickclass as rC

    root = Tk.Tk()
    root.title('Tool')
    Pmw.initialise(root)
    
    Mainframe = Tk.Frame(root, width=215, height=210)
    class AtsMenuBar:
        def __init__(self):
            menuBar=Pmw.MenuBar(Mainframe, hull_relief='raised', hull_borderwidth=1)
            menuBar.pack(fill='x')
        
            sc2 = Pmw.ScrolledFrame(Mainframe)  #
            sc2.pack(fill='x', expand=1, padx=2, pady=2)
            sc2.place(relx=0.25, rely=0.25, anchor='nw')
            HashBox1 = Pmw.EntryField(sc2.interior(), labelpos='w', labelmargin=1,
         validate = None)
        
            HashBox1.pack(fill='x', expand=1, padx=1, pady=1)
            
                
    menu = AtsMenuBar()
    Mainframe.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
    Mainframe.pack_propagate(0)
    
    u = rC.rClick(root, "PMW_test")
    root.mainloop()
Example #30
0
    def __init__(self,root,database,tipo='data'):
        self.tty=int(cp.getoption('tty'))
        self.func_gen=int(cp.getoption('func_gen'))
        self.tty_read=int(cp.getoption('tty_read'))
        self.freq_min=float(cp.getoption('freq_min'))
        self.freq_max=float(cp.getoption('freq_max'))
        self.sweep_min=int(cp.getoption('sweep_min'))
        self.root=root
        self.root.protocol('WM_DELETE_WINDOW', self.close)
#        self.plls={50:11,62.5:9,100:7,200:1}
        self.plls={50:11,62:9,100:7,125:3,200:1} # actually 62.5:9 MHz
        self.database=database
        self.tipo=tipo
        self.oper=0
        if not path.exists("/dev/pcie0"):
            try:
                system("sudo /home/GRS/driver_ATCA/driver/mknod.sh")
                system("sleep 1")
            except:
                Pmw.displayerror('Não foi possível carregar os drivers!')                
        if self.tty==1:
            self.HTO_prog=ttyS0comm.HTO_prog(self.tty_read)
        if self.func_gen==1:
            self.agilent=agilentcomm.Agilent_prog()
            if not self.agilent.check:
                self.func_gen=0
        self.server = TCPIPserverTask()
        self.choose()
    def load(self):
        #start over with frames
        self.sc.destroy()
        #scrollbar
        self.sc = Pmw.ScrolledFrame(self.parent, usehullsize=1, hull_height = 650)
        self.sc.pack(anchor = NW, fill = 'both')


        #clear frame list for rebuilding
        self.frame_list.clear()


    #get filename for opening
        name = fd.askopenfilename(filetypes=[('CSV', '*.csv',), ('Excel', ('*.xls', '*.xlsx'))])

        #make sure name is populated
        if name:
            #if csv, use read_csv to create the self.dataframe
            if name.endswith('.csv'):
                self.df = pd.read_csv(name)
            #otherwise, it must be an excel file
            else:
                self.df = pd.read_excel(name)
            #save the filename for reference
            self.filename = name
#%%
        if self.df is not None:
            field_list = list(self.df.columns)

            #instantiate the swap var list, in case it's not changed
            self.swap_var_list = field_list.copy()

            #create a new frame with each field
            for field in field_list:
                #create new frame instance, pass field name as frame name
                    #duplicate field names is going to cause issues
                my_frame = MyFrame()
                my_frame._init_(field)

                #add to list of frames so you can later iterate
                self.frame_list.append(my_frame)

                left_frame = tk.LabelFrame(self.sc.interior(),text=field,name=str(field.lower()))
                left_frame.pack(side=tk.LEFT)
                #put the name on the list of frame widgets
                self.widget_frame_list.append(str(field.lower()))


#%%
        #SORT FUNCTION
                #sort modes for radio button widget
                modes = [('Sort Ascending','A'),('Sort Descending','D'),('Do Not Sort','N')]
                for text, mode in modes:
                    b = Radiobutton(left_frame, text=text, variable=my_frame.sort_var, value=mode, indicatoron =0)
                    b.pack(side=tk.BOTTOM,anchor=W)

#%%
        #Pivot FUNCTION
                #sort modes for radio button widget
                pivot_modes = [('Pivot Row','R'),('Pivot Column','C'),('Pivot Value','V'),('Do not include in Pivot','N')]
                for text, mode in pivot_modes:
                    b = Radiobutton(left_frame, text=text, variable=my_frame.pivot_var, value=mode, indicatoron =0)
                    b.pack(side=tk.BOTTOM,anchor=W)

#%%

            #filter boxes

                filter_Entry = Entry(left_frame,textvariable=my_frame.filter_var).pack(side = tk.BOTTOM)
                #change all to lowercase here or within the function to do the filtering


#%%
            #create rename box
                rename_Entry = Entry(left_frame,textvariable=my_frame.rename_var).pack(side = tk.BOTTOM)




#%%
                #create delete box
                #DELETE
                b = Checkbutton(left_frame, text='Delete', variable = my_frame.delete_var, onvalue = 'D', offvalue = 'N' )
                b.pack(side=BOTTOM, anchor = W)




#%%

                #create text area for display.  on top of current frame
                self.text = tk.Text(left_frame,width=20, height = 17)
                self.text.pack(side=tk.BOTTOM)
                #for the current field, get the contents in a df

                col_df = self.df[field]

                self.text.insert('end', str(col_df) + '\n')
Example #32
0
    def Host_Vector(self):
        self.hide()
        hVFrame = Toplevel()
        hVFrame.title("SIR WITH HOST VECTORS")
        hVFrame.geometry("700x800")
        # self.top.transient(self)
        g = Pmw.Blt.Graph(hVFrame)
        g.pack(expand=1, fill="both")
        E = zeros([3, 1])
        A = zeros([3, 3])
        C = zeros([3, 1])
        A = zeros([3, 3])
        B = zeros([2, 2])
        E = zeros([3, 1])
        C = zeros([3, 1])
        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        # Textfields
        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        global sus1, sus2, sus3, contact1, contact2, contact3, time_interval, death_rate1, death_rate2
        global death_rate3, recovery1, recovery2, recovery3
        sus1 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Susceptibles1-S1",
            validate={"validator": "real"},
        )
        sus1.pack(expand=1, padx=5, pady=5)
        sus2 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Susceptibles2-S2",
            validate={"validator": "real"},
        )
        sus2.pack(expand=1, padx=1, pady=2)
        sus3 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Susceptibles3-S3 ",
            validate={"validator": "real"},
        )
        sus3.pack(expand=1, padx=1, pady=2)
        contact1 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate 1-k12",
            validate={"validator": "real"},
        )
        contact1.pack(expand=1, padx=1, pady=2)
        contact2 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate 2-k21",
            validate={"validator": "real"},
        )
        contact2.pack(expand=1, padx=1, pady=2)
        contact3 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate 3-k23",
            validate={"validator": "real"},
        )
        contact3.pack(expand=1, padx=1, pady=2)
        contact4 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate 4-k32",
            validate={"validator": "real"},
        )
        contact4.pack(expand=1, padx=1, pady=2)
        time_interval = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0",
            label_text=" Time    Interval-t ",
            validate={"validator": "numeric"},
        )
        time_interval.pack(expand=1, padx=1, pady=2)
        death_rate1 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text=" Death  Rate 1-d1 ",
            validate={"validator": "real"},
        )
        death_rate1.pack(expand=1, padx=1, pady=2)
        death_rate2 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text=" Death  Rate 2-d2 ",
            validate={"validator": "real"},
        )
        death_rate2.pack(expand=1, padx=1, pady=2)
        death_rate3 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.0",
            label_text=" Death  Rate 3-d3 ",
            validate={"validator": "real"},
        )
        death_rate3.pack(expand=1, padx=1, pady=2)
        recovery1 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.00",
            label_text="Recovery Rate 1",
            validate={"validator": "real"},
        )
        recovery1.pack(expand=1, padx=1, pady=2)
        recovery2 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.00",
            label_text="Recovery Rate 2",
            validate={"validator": "real"},
        )
        recovery2.pack(expand=1, padx=1, pady=2)
        recovery3 = Pmw.EntryField(
            hVFrame,
            labelpos="w",
            value="0.00",
            label_text="Recovery Rate 3",
            validate={"validator": "real"},
        )
        recovery3.pack(expand=1, padx=1, pady=2)

        # ------------------------------------------------------------------------------------------------------------------------------------------------------
        # self.top.transient(self)
        # self.wButton.config(state='disabled')
        def retrive():
            k12 = float(contact1.get())
            k21 = float(contact2.get())
            k23 = float(contact3.get())
            k32 = float(contact4.get())
            ddelta1 = float(death_rate1.get())
            ddelta2 = float(death_rate2.get())
            ddelta3 = float(death_rate3.get())
            ggamma1 = float(recovery1.get())
            ggamma2 = float(recovery2.get())
            ggamma3 = float(recovery3.get())
            N = int(time_interval.get())
            s0 = float(sus1.get())
            I0 = float(sus2.get())
            R0 = float(sus3.get())
            A[0][0] = 0
            A[0][1] = k12
            A[0][2] = 0
            A[1][0] = k21
            A[1][1] = 0
            A[1][2] = k23
            A[2][0] = 0
            A[2][1] = k32
            A[2][2] = 0
            B[0][0] = 0
            B[0][1] = 0
            B[1][0] = 0
            B[1][1] = 0
            E[0][0] = -k12 - (ggamma1 + ddelta1)
            E[1][0] = -k21 - k23 - (ggamma2 + ddelta2)
            E[2][0] = -k32 - (ggamma3 + ddelta3)
            C[0][0] = ddelta1 + ggamma1
            C[1][0] = ddelta2 + ggamma2
            C[2][0] = ddelta3 + ggamma3

            def f1(s1, I1, R1):
                s_dot = s1 * E[0][0] + A[0][1] * s1 * I1 + C[0][0]
                return s_dot

            def f2(s1, I1, R1):
                I_dot = I1 * E[1][0] + A[1][0] * s1 * I1 + A[1][2] * I1 * R1 + C[1][0]
                return I_dot

            def f3(s1, I1, R1):
                R_dot = E[2][0] * R1 + A[2][1] * I1 * R1 + C[2][0]
                return R_dot

            # =========RATE OF CHANGE OF THE MODEL WITH RESPECT TO TIME AND DECLARATON OF CONSTANTS==============================================================
            t = arange(0, N, 0.02455)
            s1 = zeros(len(t))
            I1 = zeros(len(t))
            R1 = zeros(len(t))
            s1[0] = s0
            I1[0] = I0
            R1[0] = R0
            h = 0.01

            # ==========ITERATION FOR A GIVEN TIME INTERVAL======================================================================================================

            for n in range(len(t) - 1):
                s1[n + 1] = s1[n] + h * (f1(s1[n], I1[n], R1[n]))
                I1[n + 1] = I1[n] + h * (f2(s1[n], I1[n], R1[n]))
                R1[n + 1] = R1[n] + h * (f3(s1[n], I1[n], R1[n]))
            x_ = tuple(t)
            y_ = tuple(s1)
            z_ = tuple(I1)
            w_ = tuple(R1)
            g.configure(
                title="A graph of Susceptible and Infective  against time for SIR with Host-Vector"
            )
            g.line_create(
                "S1(t) Vs t", xdata=x_, color="blue", ydata=y_, linewidth=2, symbol=""
            )
            g.line_create(
                "S2(t) Vs t", xdata=x_, color="orange", ydata=z_, linewidth=2, symbol=""
            )
            g.line_create(
                "S3(t) Vs t", xdata=x_, color="red", ydata=w_, linewidth=2, symbol=""
            )

        def postscript():
            g.postscript_output(fileName="HelloUser1.ps", decorations="no")

        def newFile():
            for name in g.element_names():
                g.element_delete(name)
            contact1.setentry("")
            contact2.setentry("")
            contact3.setentry("")
            contact4.setentry("")
            recovery1.setentry("")
            recovery2.setentry("")
            recovery3.setentry("")
            time_interval.setentry("")

            sus1.setentry("")
            sus2.setentry("")
            sus3.setentry("")
            death_rate1.setentry("")
            death_rate2.setentry("")
            death_rate3.setentry("")

        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        buttons = Pmw.ButtonBox(hVFrame, labelpos="w", label_text="Options")
        buttons = Pmw.ButtonBox(hVFrame, labelpos="w", label_text="Options")
        buttons.pack(fill="both", expand=1, padx=10, pady=10)
        buttons.add("GRID", bg="green", command=g.grid_toggle)
        buttons.add("PLOT", bg="green", command=retrive)
        buttons.add("CLEAR", bg="green", command=newFile)
        buttons.add("SAVE", bg="green", command=postscript)
        handler = lambda: self.onCloseOtherFrameV(hVFrame)
        buttons.add("QUIT", bg="red", command=handler)
Example #33
0
    def Temporary_Immunity(self):
        self.hide()
        tIFrame = Toplevel()
        tIFrame.title("SIR WITH TEMPORARY IMMUNITY")
        tIFrame.geometry("700x800")
        # self.top.transient(self)
        g = Pmw.Blt.Graph(tIFrame)
        g.pack(expand=1, fill="both")
        E = zeros([2, 1])
        A = zeros([2, 2])
        C = zeros([2, 1])
        A = zeros([2, 2])
        B = zeros([2, 2])
        E = zeros([2, 1])
        C = zeros([2, 1])
        # -------------------------------------------------------------------------------------------------------------------------------------------------------
        sus = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0.0",
            label_text="Initial Susceptibles :",
            validate={"validator": "real"},
        )
        sus.pack(expand=1, padx=5, pady=5)
        Infec = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0.0",
            label_text="Initial Infectives :",
            validate={"validator": "real"},
        )
        Infec.pack(expand=1, padx=5, pady=5)
        contact = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate (k) :",
            validate={"validator": "real"},
        )
        contact.pack(expand=1, padx=5, pady=5)
        Removal = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0.0",
            label_text=" Removal  Rate  :",
            validate={"validator": "real"},
        )
        Removal.pack(expand=1, padx=10, pady=5)
        time_interval = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0",
            label_text=" Time    Interval :",
            validate={"validator": "numeric"},
        )
        time_interval.pack(expand=1, padx=5, pady=5)
        death_rate = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0.0",
            label_text=" Death  Rate (d) :",
            validate={"validator": "real"},
        )
        death_rate.pack(expand=1, padx=10, pady=5)
        immunity = Pmw.EntryField(
            tIFrame,
            labelpos="w",
            value="0.00",
            label_text="  Immunity Rate:",
            validate={"validator": "real"},
        )
        immunity.pack(expand=1, padx=10, pady=10)
        # --------------------------------------------------------------------------------------------------------------------------------------------------------

        # self.top.transient(self)
        # self.wButton.config(state='disabled')
        def retrive():
            k1 = contact.get()
            k = float(k1)
            ddelta = float(death_rate.get())
            aalpha = float(immunity.get())
            ggamma = float(Removal.get())
            N = int(time_interval.get())
            s0 = float(sus.get())
            I0 = float(Infec.get())
            A[0][0] = 0
            A[0][1] = -k
            A[1][0] = k
            A[1][1] = 0
            B[0][0] = 0
            B[0][1] = 0
            B[1][0] = 0
            B[1][1] = 0
            E[0][0] = -(ddelta + aalpha)
            E[1][0] = -(ggamma + ddelta + +aalpha)
            C[0][0] = (ddelta + aalpha) * (1 + aalpha / k)
            C[1][0] = 0

            def f1(s1, I1):
                s_dot = (
                    s1 * E[0][0]
                    + A[0][0] * (s1 ** 2)
                    + A[0][1] * s1 * I1
                    + B[0][0] * s1
                    + B[0][1] * I1
                    + C[0][0]
                )
                return s_dot

            def f2(s1, I1):
                I_dot = (
                    I1 * E[1][0]
                    + A[1][1] * (I1 ** 2)
                    + A[1][0] * s1 * I1
                    + B[1][0] * s1
                    + B[1][1] * I1
                    + C[1][0]
                )
                return I_dot

            # =========RATE OF CHANGE OF THE MODEL WITH RESPECT TO TIME AND DECLARATON OF CONSTANTS================================================================
            t = arange(0, N, 0.02455)
            s1 = zeros(len(t))
            I1 = zeros(len(t))
            s1[0] = s0
            I1[0] = I0
            h = 0.01

            # ==========ITERATION FOR A GIVEN TIME INTERVAL=======================================================================================================

            for n in range(len(t) - 1):
                s1[n + 1] = s1[n] + h * (f1(s1[n], I1[n]))
                I1[n + 1] = I1[n] + h * (f2(s1[n], I1[n]))
            x_ = tuple(t)
            y_ = tuple(s1)
            z_ = tuple(I1)
            g.configure(
                title="Susceptible and Infectives  against time for SIR with Temporary Immunity"
            )
            g.line_create(
                "S(t) Vs t", xdata=x_, color="red", ydata=y_, linewidth=2, symbol=""
            )
            g.line_create(
                "I(t) Vs t", xdata=x_, color="orange", ydata=z_, linewidth=2, symbol=""
            )

        def postscript():
            g.postscript_output(fileName="HelloUser1.ps", decorations="no")

        def newFile():
            for name in g.element_names():
                g.element_delete(name)
            contact.setentry("")
            Removal.setentry("")
            time_interval.setentry("")
            Infec.setentry("")
            sus.setentry("")
            immunity.setentry("")
            death_rate.setentry("")

        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        buttons = Pmw.ButtonBox(tIFrame, labelpos="w", label_text="Options")
        # buttons = Pmw.ButtonBox(self, labelpos='w', label_text='Options')
        buttons.pack(fill="both", expand=1, padx=10, pady=10)
        buttons.add("GRID", bg="green", command=g.grid_toggle)
        buttons.add("PLOT", bg="green", command=retrive)
        buttons.add("CLEAR", bg="green", command=newFile)
        buttons.add("SAVE", bg="green", command=postscript)
        handler = lambda: self.onCloseOtherFrameT(tIFrame)
        buttons.add("QUIT", bg="red", command=handler)
Example #34
0
    def Vertical_Transmission(self):
        self.hide()
        vTFrame = Toplevel()
        vTFrame.title("SIR WITH VERTICAL TRANSMISSION")
        vTFrame.geometry("700x800")
        # self.top.transient(self)
        g = Pmw.Blt.Graph(vTFrame)
        g.pack(expand=1, fill="both")
        E = zeros([2, 1])
        A = zeros([2, 2])
        C = zeros([2, 1])
        A = zeros([2, 2])
        B = zeros([2, 2])
        E = zeros([2, 1])
        C = zeros([2, 1])
        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        sus = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.0",
            label_text="Initial Susceptible",
            validate={"validator": "real"},
        )
        sus.pack(expand=1, padx=5, pady=5)
        Infec = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.0",
            label_text="Initial Infective Io:",
            validate={"validator": "real"},
        )
        Infec.pack(expand=1, padx=5, pady=5)
        contact = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate - k ",
            validate={"validator": "real"},
        )
        contact.pack(expand=1, padx=5, pady=5)
        Removal = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.0",
            label_text=" Removal  Rate ",
            validate={"validator": "real"},
        )
        Removal.pack(expand=1, padx=10, pady=5)
        time_interval = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0",
            label_text=" Time    Interval",
            validate={"validator": "numeric"},
        )
        time_interval.pack(expand=1, padx=5, pady=5)
        birth_rate = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.0",
            label_text=" Birth  Rate - b :",
            validate={"validator": "real"},
        )
        birth_rate.pack(expand=1, padx=10, pady=5)
        immunity1 = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.00",
            label_text="  Immunity Rate ",
            validate={"validator": "real"},
        )
        immunity1.pack(expand=1, padx=10, pady=10)
        infected_rate = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.0",
            label_text="Infected Birth - Ib",
            validate={"validator": "real"},
        )
        infected_rate.pack(expand=1, padx=10, pady=5)
        vertical = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.00",
            label_text="  Vertical Rate - v",
            validate={"validator": "real"},
        )
        vertical.pack(expand=1, padx=10, pady=10)
        probability = Pmw.EntryField(
            vTFrame,
            labelpos="w",
            value="0.00",
            label_text="Probability loss -p",
            validate={"validator": "real"},
        )
        probability.pack(expand=1, padx=10, pady=10)
        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        # self.top.transient(self)
        # self.wButton.config(state='disabled')
        def retrive():
            k1 = contact.get()
            k = float(k1)
            ggamma = float(Removal.get())
            N = int(time_interval.get())
            s0 = float(sus.get())
            I0 = float(Infec.get())
            m = float(immunity1.get())
            v = float(vertical.get())
            b_prime = float(infected_rate.get())
            b = float(birth_rate.get())
            p = float(probability.get())
            A[0][0] = 0
            A[0][1] = -k
            A[1][0] = k
            A[1][1] = 0
            B[0][0] = (m - 1) * b + (p * b_prime + ggamma)
            B[0][1] = 0
            B[1][0] = 0
            B[1][1] = 0
            E[0][0] = -b - ggamma
            E[1][0] = p * b_prime - v
            C[0][0] = b * (1 - m) + (ggamma)
            C[1][0] = 0

            def f1(s1, I1):
                s_dot = (
                    s1 * E[0][0]
                    + A[0][0] * (s1 ** 2)
                    + A[0][1] * s1 * I1
                    + B[0][0] * s1
                    + B[0][1] * I1
                    + C[0][0]
                )
                return s_dot

            def f2(s1, I1):
                I_dot = (
                    I1 * E[1][0]
                    + A[1][1] * (I1 ** 2)
                    + A[1][0] * s1 * I1
                    + B[1][0] * s1
                    + B[1][1] * I1
                    + C[1][0]
                )
                return I_dot

            # =========RATE OF CHANGE OF THE MODEL WITH RESPECT TO TIME AND DECLARATON OF CONSTANTS==================================
            t = arange(0, N, 0.02455)
            s1 = zeros(len(t))
            I1 = zeros(len(t))
            s1[0] = s0
            I1[0] = I0
            h = 0.01

            # ==========ITERATION FOR A GIVEN TIME INTERVAL=========================

            for n in range(len(t) - 1):
                s1[n + 1] = s1[n] + h * (f1(s1[n], I1[n]))
                I1[n + 1] = I1[n] + h * (f2(s1[n], I1[n]))
            x_ = tuple(t)
            y_ = tuple(s1)
            z_ = tuple(I1)
            g.configure(
                title="Susceptible and Infectives  against time for SIR with Vertical Transmission"
            )
            g.line_create(
                "S(t) Vs t", xdata=x_, color="red", ydata=y_, linewidth=2, symbol=""
            )
            g.line_create(
                "I(t) Vs t", xdata=x_, color="orange", ydata=z_, linewidth=2, symbol=""
            )

        def postscript():
            g.postscript_output(fileName="HelloUser1.ps", decorations="no")

        def newFile():
            for name in g.element_names():
                g.element_delete(name)
            contact.setentry("")
            Removal.setentry("")
            time_interval.setentry("")
            Infec.setentry("")
            sus.setentry("")
            immunity1.setentry("")
            birth_rate.setentry("")
            vertical.setentry("")
            infected_rate.setentry("")
            probability.setentry("")

        # --------------------------------------------------------------------------------------------------------------------------------------------------------
        buttons = Pmw.ButtonBox(vTFrame, labelpos="w", label_text="Options")
        # buttons = Pmw.ButtonBox(self, labelpos='w', label_text='Options')
        buttons.pack(fill="both", expand=1, padx=10, pady=10)
        buttons.add("GRID", bg="green", command=g.grid_toggle)
        buttons.add("PLOT", bg="green", command=retrive)
        buttons.add("CLEAR", bg="green", command=newFile)
        buttons.add("SAVE", bg="green", command=postscript)
        handler = lambda: self.onCloseOtherFrame2(vTFrame)
        buttons.add("QUIT", bg="red", command=handler)
Example #35
0
    def Vital_Dynamics(self):
        self.hide()
        vDFrame = Toplevel()
        vDFrame.title("SIR WITH VITAL DYNAMICS")
        vDFrame.geometry("700x800")
        # self.top.transient(self)
        g = Pmw.Blt.Graph(vDFrame)
        g.pack(expand=1, fill="both")
        E = zeros([2, 1])
        A = zeros([2, 2])
        C = [2, 1]
        A = zeros([2, 2])
        B = zeros([2, 2])
        E = zeros([2, 1])
        C = zeros([2, 1])

        # ===============CREATE, PACK AND VALIDATE THE TEXTFIELD FOR DATA ENTRY================================================================================

        sus = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0.0",
            label_text="Initial Susceptibles :",
            validate={"validator": "real"},
        )
        sus.pack(expand=1, padx=5, pady=5)
        Infec = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0.0",
            label_text="Initial Infectives :",
            validate={"validator": "real"},
        )
        Infec.pack(expand=1, padx=5, pady=5)
        contact = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0.0",
            label_text="Contact Rate (k) :",
            validate={"validator": "real"},
        )
        contact.pack(expand=1, padx=5, pady=5)
        Removal = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0.0",
            label_text=" Removal  Rate  :",
            validate={"validator": "real"},
        )
        Removal.pack(expand=1, padx=10, pady=5)
        time_interval = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0",
            label_text=" Time    Interval :",
            validate={"validator": "numeric"},
        )
        time_interval.pack(expand=1, padx=5, pady=5)
        death_rate = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0.0",
            label_text=" Death  Rate (d) :",
            validate={"validator": "real"},
        )
        death_rate.pack(expand=1, padx=10, pady=5)
        immunity = Pmw.EntryField(
            vDFrame,
            labelpos="w",
            value="0.00",
            label_text="  Immunity Rate:",
            validate={"validator": "real"},
        )
        immunity.pack(expand=1, padx=10, pady=10)
        # -------------------------------------------------------------------------------------------------------------------------------------------------------

        def retrive():
            k1 = contact.get()
            k = float(k1)
            ddelta = float(death_rate.get())
            aalpha = float(immunity.get())
            ggamma = float(Removal.get())
            N = int(time_interval.get())
            s0 = float(sus.get())
            I0 = float(Infec.get())
            A[0][0] = 0
            A[0][1] = -k
            A[1][0] = k
            A[1][1] = 0
            B[0][0] = 0
            B[0][1] = 0
            B[1][0] = 0
            B[1][1] = 0
            E[0][0] = -ddelta
            E[1][0] = -(ggamma + ddelta)
            C[0][0] = ddelta
            C[1][0] = 0

            # =========GENERAL DECLARATION SECTION FOR THE BILINEAR FORM=============================================================================================

            def f1(s1, I1):
                s_dot = (
                    s1 * E[0][0]
                    + A[0][0] * (s1 ** 2)
                    + A[0][1] * s1 * I1
                    + B[0][0] * s1
                    + B[0][1] * I1
                    + C[0][0]
                )
                return s_dot

            def f2(s1, I1):
                I_dot = (
                    I1 * E[1][0]
                    + A[1][1] * (I1 ** 2)
                    + A[1][0] * s1 * I1
                    + B[1][0] * s1
                    + B[1][1] * I1
                    + C[1][0]
                )
                return I_dot

            # =========RATE OF CHANGE OF THE MODEL WITH RESPECT TO TIME AND DECLARATON OF CONSTANTS==================================================================
            t = arange(0, N, 0.02455)
            s1 = zeros(len(t))
            I1 = zeros(len(t))
            s1[0] = s0
            I1[0] = I0
            h = 0.01

            # ==========ITERATION FOR A GIVEN TIME INTERVAL========================================================================================================

            for n in range(len(t) - 1):
                s1[n + 1] = s1[n] + h * (f1(s1[n], I1[n]))
                I1[n + 1] = I1[n] + h * (f2(s1[n], I1[n]))

            # =========PLOTTING AND FORMATTING=====================================================================================================================

            x_ = tuple(t)
            y_ = tuple(s1)
            z_ = tuple(I1)
            g.configure(
                title="Susceptible and Infectives  against time for SIR with vital dynamics"
            )
            g.line_create(
                "S(t) Vs t", xdata=x_, color="blue", ydata=y_, linewidth=2, symbol=""
            )
            g.line_create(
                "I(t) Vs t", xdata=x_, color="orange", ydata=z_, linewidth=2, symbol=""
            )

        def postscript():
            g.postscript_output(fileName="HelloUser2.eps", decorations="no")

        def newFile():
            for name in g.element_names():
                g.element_delete(name)
            contact.setentry("")
            Removal.setentry("")
            time_interval.setentry("")
            Infec.setentry("")
            sus.setentry("")
            immunity.setentry("")
            death_rate.setentry("")

        # =========CREATE AND PACK BUTTONS, LABELS USING Pmw PACKAGE IN PYTHON===============================================================================

        buttons = Pmw.ButtonBox(vDFrame, labelpos="w", label_text="Options")
        buttons = Pmw.ButtonBox(vDFrame, labelpos="w", label_text="Options")
        buttons.pack(fill="both", expand=1, padx=10, pady=10)
        buttons.add("GRID", bg="green", command=g.grid_toggle)
        buttons.add("PLOT", bg="green", command=retrive)
        buttons.add("CLEAR", bg="green", command=newFile)
        buttons.add("SAVE", bg="green", command=postscript)
        handler = lambda: self.onCloseOtherFrame1(vDFrame)
        buttons.add("QUIT", bg="red", command=handler)
Example #36
0
#?    dbgcnt -= 1
#?    if  dbgcnt > 0:
#?	root.after( 1000, RootRefresh )

######################################################################
################   root operations   #################################
######################################################################

StatIOsource = StatIO_ScreenPrintSim
TelStat_cfg.OSSC_screenPrintPath = OSSC_SCREENPRINTSIMPATH

# Instantiate a Pmw/Tk object and set its tk_strictMotif attribute for strict
#	Motif compliance
root = Tkinter.Tk()
Pmw.initialise(root)
root.tk_strictMotif(1)
root["bg"] = "black"
root.iconname('EnvPaneTest')
root.title('EnvPaneTest')
root.protocol('WM_DELETE_WINDOW', EndProc)
root.geometry("300x360")

# Set signal handler for various signals
signal.signal(signal.SIGINT, SigHandler)
signal.signal(signal.SIGTERM, SigHandler)
signal.signal(signal.SIGUSR1, SigHandler)
signal.signal(signal.SIGUSR2, SigHandler)

# Create pane
tpPane = EnvPane(root)
Example #37
0
    def __init__(self, parent, sequences):
        self.parent_frame = parent.parent_frame
        self.sequences = sequences
        self.parent = parent
        self.reactions_top = Tkinter.Toplevel(self.parent_frame)
        self.reactions_top.title('Modification Manager')
        self.reactions_top.wm_transient(self.parent_frame)
        p_geo = self.parent_frame.geometry()
        args = string.split(p_geo, 'x')
        arg1 = args[0]
        args = string.split(args[1], '+')
        geometry_string = "%dx%d%+d%+d" % (500, 450, int(
            args[1]) + 25, int(args[2]) + 25)  # width,height,x-offset,y-offset
        self.reactions_top.geometry(geometry_string)
        self.colormap = {
            'color1': "#aaf",
            'color2': "#afa",
            'color3': "#aff",
            'color4': "#faa",
            'color5': "#faf",
            'color6': "#ffa",
            'color7': "#88b",
            'color8': "#8b8",
            'color9': "#8bb",
            'color10': "#b88",
            'color11': "#b8b",
            'color12': "#bb8",
            'color13': "#aab",
            'color14': "#aba",
            'color15': "#abb",
            'color16': "#baa",
            'color17': "#bab",
            'color18': "#bba"
        }
        self.colorkeys = self.colormap.keys()
        self.colorkeys.sort()
        # available reagents
        self.reactions_dict = {}
        filename = './Tools/MassSpectrometry/reactions_dict.pkl'
        if os.path.exists(filename):
            reactions_file = open(filename, 'rb')
            self.reactions_dict = pickle.load(reactions_file)
            reactions_file.close()
        else:
            print 'no reactions file %s found' % (filename)
        keys = self.reactions_dict.keys()

        self.modifying_reagents = keys

        self.temp_reactant_dict = copy.deepcopy(self.reactions_dict)
        #frames
        self.tiptop_frame = Tkinter.Frame(self.reactions_top,
                                          borderwidth=2,
                                          relief='groove')
        self.top_frame = Tkinter.Frame(self.reactions_top)
        self.left_frame = Tkinter.Frame(self.top_frame,
                                        borderwidth=2,
                                        relief='groove')
        self.right_frame = Tkinter.Frame(self.top_frame,
                                         borderwidth=2,
                                         relief='groove')
        self.bottom_frame = Tkinter.Frame(self.reactions_top)

        # create a scrolledlistbox to hold the reactions
        rxn_keys = self.reactions_dict.keys()
        self.reactant_titles_dropdown = Pmw.ComboBox(
            self.left_frame,
            label_text='Common Reactions',
            labelpos='nw',
            selectioncommand=self._view_reactant,
            scrolledlist_items=rxn_keys)
        if len(rxn_keys) > 0:
            self.reactant_titles_dropdown.selectitem(rxn_keys[0])
        self.reactant_titles_dropdown.pack(side='top', fill='x', expand=1)

        self.reactants_button_box = Pmw.ButtonBox(self.left_frame)
        self.reactants_save_button = self.reactants_button_box.add(
            'Add', command=self._add_reactant)
        self.reactant_manager_cancel_button = self.reactants_button_box.add(
            'Remove', command=self._remove_reactant)
        self.reactants_button_box.add('Import', command=self._import_reactants)
        self.reactants_button_box.pack(side='top', fill='x', expand=1)

        if len(rxn_keys) > 0:
            self.reactant_name_message = rxn_keys[0]
        else:
            self.reactant_name_message = ""
        self.reactant_name_text = Tkinter.StringVar(self.right_frame)
        self.reactant_name_text.set(self.reactant_name_message)

        self.reactant_name_label = Tkinter.Label(
            self.right_frame,
            textvariable=self.reactant_name_text,
            bg=self.colormap[self.colorkeys[0]])

        self.reactant_manager_button_box = Pmw.ButtonBox(self.bottom_frame)
        # support the import of reactants from the pickled mods dictionary
        file = open('./Tools/MassSpectrometry/mods.pkl', 'rb')
        mods = pickle.load(file)
        file.close()
        modskeys = mods.keys()
        modskeys.sort()
        all_keys = []
        for modskey in modskeys:
            newkeys = mods[modskey].keys()
            newkeys.sort()
            for key in newkeys:
                all_keys.append(key)
        self.which_mod = Pmw.ComboBoxDialog(
            self.reactions_top,
            title='Select a reaction to import',
            buttons=('OK', 'Cancel'),
            defaultbutton='OK',
            combobox_labelpos='n',
            scrolledlist_items=(all_keys))
        self.which_mod.withdraw()
        self.reactant_manager_save_button = self.reactant_manager_button_box.add(
            'Save', command=self._save_reactants)
        self.reactant_manager_save_button.config(state='disabled')

        self.reactant_manager_cancel_button = self.reactant_manager_button_box.add(
            'Discard Changes', command=self._discard_reactant_manager_changes)
        self.reactant_manager_cancel_button = self.reactant_manager_button_box.add(
            'Close', command=self._close_reactant_manager)

        self.reactant_added_weight_entry = Pmw.EntryField(
            self.right_frame,
            labelpos='w',
            label_text='Weight added to residue',
            validate={'validator': 'real'},
            modifiedcommand=self._update_temp_reactant_dict_weight)
        if len(rxn_keys) > 0:
            self.reactant_added_weight_entry.setvalue(
                self.reactions_dict[rxn_keys[0]]['added_weight'])

        self.reactant_target_AA_entry = Pmw.EntryField(
            self.right_frame,
            labelpos='w',
            label_text='Target Residue 1-letter codes',
            validate={'validator': self._validate_one_letter_codes},
            modifiedcommand=self._update_temp_reactant_dict_target_AA)
        if len(rxn_keys) > 0:
            self.reactant_target_AA_entry.setvalue(
                self.reactions_dict[rxn_keys[0]]['target_AA'])

        # now build a text box to hold the sequences for modification
        textfont = ('courier', 10)
        self.sequence_box = Pmw.ScrolledText(self.tiptop_frame,
                                             text_font=textfont,
                                             text_height=20)
        for sequence in self.sequences:
            self.sequence_box.appendtext('%s\n\n' % (sequence))
        self.add_reactant_popup = Tkinter.Menu(self.reactions_top, tearoff=0)
        self.sequence_box.component('text').bind("<Button-3>", self.popup_menu)

        self.sequence_box.pack(side='top', expand=1, fill='x')
        self.reactant_name_label.pack(side='top', expand=0, fill='x')
        self.reactant_added_weight_entry.pack(side='top', expand=1, fill='x')
        self.reactant_target_AA_entry.pack(side='top', expand=1, fill='x')
        self.tiptop_frame.pack(side='top', expand=1, fill='x')
        self.left_frame.pack(side='left', expand=1, fill='both')
        self.right_frame.pack(side='left', expand=1, fill='both')
        self.top_frame.pack(side='top', expand=1, fill='both')
        self.reactant_manager_button_box.pack(fill='x', expand=1)
        self.bottom_frame.pack(side='top', expand=1, fill='x')
        self._save_reactants()
def _createWindow():
    w = Test.currentWidget()
    lb = Pmw.ScrolledListBox(w.interior(),
                             items=list(range(20)),
                             listbox_height=6)
    w.create_window(300, 100, window=lb)
                message.append("AGENT     = %s" % ` event["AGENT"] `)
                message.append("STATUS    = %s" % ` event["STATUS"] `)
                message.append("")
                message.append("")
                message = string.joinfields(message, "\n")
                self._appendLog(message)

        self._monitor.resumeEvents()

        subjects = self._subjects.keys()
        subjects.sort()

        view = []
        for subject in subjects:
            view.append(subject + " = " + self._subjects[subject])
        self._subjectView.setlist(view)

        self.update_idletasks()

    def _widgetDestroyed(self, *args):
        if self._timer:
            self.after_cancel(self._timer)
            self._timer = None
        if self._monitor is not None:
            job = netsvc.Job(self._monitor.destroyAgent)
            netsvc.Dispatcher().schedule(job, netsvc.STANDARD_JOB)
            self._monitor = None


Pmw.forwardmethods(ReportViewer, Pmw.ScrolledListBox, "_subjectView")
Example #40
0
    def createInterface(self):
        # The interior of the toplevel panel
        interior = self.interior()
        mainFrame = Frame(interior)
        ## Creat NoteBook
        self.notebookFrame = Pmw.NoteBook(mainFrame)
        self.notebookFrame.pack(fill=tkinter.BOTH, expand=1)
        sgePage = self.notebookFrame.add('Tree Graph')
        envPage = self.notebookFrame.add('World Setting')
        self.notebookFrame['raisecommand'] = self.updateInfo

        ## Tree Grapgh Page
        self.SGE = seSceneGraphExplorer.seSceneGraphExplorer(
            sgePage,
            nodePath=render,
            scrolledCanvas_hull_width=270,
            scrolledCanvas_hull_height=570)
        self.SGE.pack(fill=tkinter.BOTH, expand=0)

        ## World Setting Page
        envPage = Frame(envPage)
        pageFrame = Frame(envPage)
        self.LightingVar = IntVar()
        self.LightingVar.set(self.lightEnable)
        self.LightingButton = Checkbutton(pageFrame,
                                          text='Enable Lighting',
                                          variable=self.LightingVar,
                                          command=self.toggleLights)
        self.LightingButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.CollisionVar = IntVar()
        self.CollisionVar.set(self.collision)
        self.CollisionButton = Checkbutton(pageFrame,
                                           text='Show Collision Object',
                                           variable=self.CollisionVar,
                                           command=self.showCollision)
        self.CollisionButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.ParticleVar = IntVar()
        self.ParticleVar.set(self.ParticleEnable)
        self.ParticleButton = Checkbutton(pageFrame,
                                          text='Show Particle Dummy',
                                          variable=self.ParticleVar,
                                          command=self.enableParticle)
        self.ParticleButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.baseUseDriveVar = IntVar()
        self.baseUseDriveVar.set(self.basedriveEnable)
        self.baseUseDriveButton = Checkbutton(pageFrame,
                                              text='Enable base.usedrive',
                                              variable=self.baseUseDriveVar,
                                              command=self.enablebaseUseDrive)
        self.baseUseDriveButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.backfaceVar = IntVar()
        self.backfaceVar.set(self.backface)
        self.backfaceButton = Checkbutton(pageFrame,
                                          text='Enable BackFace',
                                          variable=self.backfaceVar,
                                          command=self.toggleBackface)
        self.backfaceButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.textureVar = IntVar()
        self.textureVar.set(self.texture)
        self.textureButton = Checkbutton(pageFrame,
                                         text='Enable Texture',
                                         variable=self.textureVar,
                                         command=self.toggleTexture)
        self.textureButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.wireframeVar = IntVar()
        self.wireframeVar.set(self.wireframe)
        self.wireframeButton = Checkbutton(pageFrame,
                                           text='Enable Wireframe',
                                           variable=self.wireframeVar,
                                           command=self.toggleWireframe)
        self.wireframeButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.gridVar = IntVar()
        self.gridVar.set(self.grid)
        self.gridButton = Checkbutton(pageFrame,
                                      text='Enable Grid',
                                      variable=self.gridVar,
                                      command=self.toggleGrid)
        self.gridButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.widgetVisVar = IntVar()
        self.widgetVisVar.set(self.widgetVis)
        self.widgetVisButton = Checkbutton(pageFrame,
                                           text='Enable WidgetVisible',
                                           variable=self.widgetVisVar,
                                           command=self.togglewidgetVis)
        self.widgetVisButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.enableAutoCameraVar = IntVar()
        self.enableAutoCameraVar.set(self.enableAutoCamera)
        self.enableAutoCameraButton = Checkbutton(
            pageFrame,
            text='Enable Auto Camera Movement for Loading Objects',
            variable=self.enableAutoCameraVar,
            command=self.toggleAutoCamera)
        self.enableAutoCameraButton.pack(side=tkinter.LEFT, expand=False)
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        pageFrame = Frame(envPage)
        self.backgroundColor = ColorEntry(pageFrame,
                                          text='BG Color',
                                          value=self.worldColor)
        self.backgroundColor['command'] = self.setBackgroundColorVec
        self.backgroundColor['resetValue'] = [0, 0, 0, 0]
        self.backgroundColor.pack(side=tkinter.LEFT, expand=False)
        self.bind(self.backgroundColor, 'Set background color')
        pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True)

        envPage.pack(expand=False)

        ## Set all stuff done
        self.notebookFrame.setnaturalsize()
        mainFrame.pack(fill='both', expand=1)
Example #41
0
        cmd = self['dblclickcommand']
        if isinstance(cmd, collections.Callable):
            cmd()

    def _celldblclick(self, event):
        #print 'double click cell'
        cmd = self['dblclickcommand']
        if isinstance(cmd, collections.Callable):
            cmd()


if __name__ == '__main__':

    rootWin = tkinter.Tk()

    Pmw.initialise()

    rootWin.title('MultiColumnListbox Demo')
    rootWin.configure(width=500, height=300)
    rootWin.update()

    def dbl():
        print(listbox.getcurselection())

    listbox = MultiColumnListbox(
        rootWin,
        #usehullsize = 1,
        labellist=(
            'Column 0',
            'Column 1',
            'Column 2',
    def __init__(self, parent=None, **kw):
        optiondefs = (("service", None, Pmw.INITOPT),
                      ("identity", None, Pmw.INITOPT), ("subject", "*",
                                                        Pmw.INITOPT))

        self.defineoptions(kw, optiondefs)

        Pmw.MegaWidget.__init__(self, parent)

        self._service = ""
        self._subject = self["subject"]

        self._subjects = {}

        self._logState = "stopped"
        self._eventLog = ""

        self._version = 0

        f1 = Tkinter.Frame(self.interior())
        f1.pack(side="top", fill="both", expand="true")

        p3 = Pmw.PanedWidget(f1,
                             orient="vertical",
                             hull_width=400,
                             hull_height=550)
        p3.pack(side="top", padx=4, pady=4, fill="both", expand="true")

        p3.add("top", size=300, min=200)
        p3.add("bottom", min=150)

        f3a = Tkinter.Frame(p3.pane("top"))
        f3a.pack(side="top", fill="both", expand="true")

        f3b = Tkinter.Frame(f3a)
        f3b.pack(side="top", fill="both", expand="true")

        f3c = Tkinter.Frame(f3b)
        f3c.pack(side="top")

        f3 = Tkinter.Frame(f3c)
        f3.pack(side="left", fill="both", expand="true")

        self._serviceField = self.createcomponent("group", (),
                                                  None,
                                                  Pmw.EntryField, (f3, ),
                                                  labelpos="w",
                                                  entry_width=25,
                                                  label_text="Service:",
                                                  validate=None)
        self._serviceField.pack(side="top", padx=8, pady=8)

        self._identityField = self.createcomponent("identity", (),
                                                   None,
                                                   Pmw.EntryField, (f3, ),
                                                   labelpos="w",
                                                   entry_width=25,
                                                   label_text="Identity:",
                                                   validate=None)
        self._identityField.pack(side="top", padx=8, pady=8)

        self._subjectField = self.createcomponent("service", (),
                                                  None,
                                                  Pmw.EntryField, (f3, ),
                                                  labelpos="w",
                                                  entry_width=25,
                                                  label_text="Subject:",
                                                  validate=None,
                                                  value="*")
        self._subjectField.pack(side="top", padx=8, pady=8)

        Pmw.alignlabels((self._serviceField, self._subjectField))

        b2 = Pmw.ButtonBox(f3c, orient="horizontal")
        b2.pack(side="left", padx=4, pady=4)
        b2.add("Subscribe", command=self._subscribeService)

        self._subjectView = Pmw.ScrolledListBox(f3b, listbox_height=15)
        self._subjectView.pack(side="top",
                               padx=4,
                               pady=8,
                               fill="both",
                               expand="true")

        f4 = Tkinter.Frame(p3.pane("bottom"))
        f4.pack(side="top", fill="both", expand="true")

        self._eventView = Pmw.ScrolledText(f4,
                                           text_padx=4,
                                           text_pady=4,
                                           text_wrap="char",
                                           text_state="disabled",
                                           text_height=5,
                                           borderframe=1)
        self._eventView.yview("moveto", 1.0)
        self._eventView.pack(side="top",
                             padx=4,
                             pady=8,
                             fill="both",
                             expand="true")

        self._eventButtons = Pmw.ButtonBox(f4, orient="horizontal")
        self._eventButtons.pack(side="bottom", padx=8, pady=8)
        self._eventButtons.add("Start", width=7, command=self._startLog)
        self._eventButtons.add("Suspend",
                               width=7,
                               state="disabled",
                               command=self._suspendLog)
        self._eventButtons.add("Clear", width=7, command=self._clearLog)

        self.bind("<Destroy>", self._widgetDestroyed)

        if self["service"] is not None:
            self._startLog()

        self._monitor = None

        if self["service"] is not None:
            self._serviceField.setvalue(self["service"])
            if self["identity"] is not None:
                self._identityField.setvalue(self["identity"])
            self._subjectField.setvalue(self["subject"])
            self._subscribeService()
            self._eventView.yview("moveto", 1.0)

        self._timer = self.after(100, self._wakeup)
Example #43
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 t_name='default',
                 o_name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            ##             import Canvas
            ##             self.canvas = Canvas.Canvas()
            self.canvas = vcs_legacy.init()
        else:
            self.canvas = canvas

        self.text = self.canvas.gettext(t_name, o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error ' + t_name + ' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error ' + o_name + ' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent = Parent
        try:
            self.parent_Name = self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig = []
        self.save_vals()

        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color

        #################################################################################################
        # At the moment, this will never happen. When we need to pop this editor up on its own, then we
        # will revist this case.
        #        if self.gui_parent is None:
        #            self.gui_parent=Tkinter.Toplevel()
        #            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
        #            self.gui_parent.withdraw()
        #################################################################################################

        title = 'Text Editor - table: ' + self.text.Tt_name + ', orientation: ' + self.text.To_name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Text Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open textobject file',
            label='Open TextObject File',
            command=gui_control.Command(self.evt_open_file, master),
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
        ##                                     label = 'Select Table',
        ##                                     command = self.evt_loadtable,
        ##                                     )
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
        ##                                     label = 'Select Orientation',
        ##                                     command = self.evt_loadorientation,
        ##                                     )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save TextObject',
            label='Save (i.e Apply changes)',
            command=self.setfont,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Table',
            label='Copy Table',
            command=gui_control.Command(self.evt_save_table_as, self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Orientation',
            label='Copy Orientation',
            command=gui_control.Command(self.evt_save_orientation_as,
                                        self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=gui_control.Command(self.evt_save_to_file, master),
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close TextObject Editor',
            label="Exit TextObject Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Table',
            tag_bg=Tt_color,
            tagindent=10,
            hull_bg=Tt_color,
            hull_highlightbackground=Tt_color,
            hull_highlightcolor=Tt_color,
            ring_bg=Tt_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables = self.canvas.listelements('texttable')
        tables.sort()

        labels = []
        self.table = Pmw.OptionMenu(
            self.tproperties,
            items=tables,
            labelpos='w',
            label_text='Name:',
            command=self.loadtable,
            initialitem=self.text.Tt_name,
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
        )
        self.table.pack()
        labels.append(self.table)

        fonts = self.canvas.listelements("font")
        self.font = Pmw.OptionMenu(
            self.tproperties,
            items=fonts,
            labelpos='w',
            label_text='Font:',
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
            command=self.setfont,
        )
        self.font.pack()
        labels.append(self.font)

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Spacing:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.spacing = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=-50,
            to=50,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.expansion = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=50,
            to=150,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=Tt_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels = []
        self.oprop = Pmw.Group(parent,
                               tag_text='Orientation',
                               tagindent=10,
                               tag_bg=To_color,
                               ring_bg=To_color,
                               hull_bg=To_color)
        self.oprop.pack(expand='yes', fill='both')
        self.oproperties = self.oprop.interior()
        self.oproperties.configure(bg=To_color)

        orientations = self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation = Pmw.OptionMenu(
            self.oproperties,
            items=orientations,
            labelpos='w',
            label_text='Name:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.loadorientation,
            initialitem=self.text.To_name,
        )
        self.orientation.pack()
        labels.append(self.orientation)

        self.height = Pmw.EntryField(
            self.oproperties,
            label_text='Size:',
            labelpos='w',
            label_justify='left',
            label_bg=To_color,
            hull_bg=To_color,
            validate={
                'min': 0,
                'validator': 'real'
            },
            command=self.setfont,
        )
        self.height.pack()
        labels.append(self.height)

        f = Tkinter.Frame(self.oproperties, bg=To_color)
        l = Tkinter.Label(
            f,
            text='Angle:',
            bg=To_color,
        )
        l.pack(side='left')
        labels.append(l)
        self.angle = Tkinter.Scale(
            f,
            bigincrement=30,
            from_=-180,
            to=180,
            orient='horizontal',
            tickinterval=90,
            length=200,
            bg=To_color,
            activebackground=To_color,
            highlightbackground=To_color,
            command=self.setfont,
        )
        self.angle.pack()
        f.pack()

        paths = ["right", "left", "up", "down"]
        self.path = Pmw.OptionMenu(
            self.oproperties,
            items=paths,
            labelpos='w',
            label_text='Path:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.path.pack()
        labels.append(self.path)

        haligns = ["left", "center", "right"]
        self.halign = Pmw.OptionMenu(
            self.oproperties,
            items=haligns,
            labelpos='w',
            label_text='Halign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.halign.pack()
        labels.append(self.halign)

        valigns = ["top", "cap", "half", "base", "bottom"]
        self.valign = Pmw.OptionMenu(
            self.oproperties,
            items=valigns,
            labelpos='w',
            label_text='Valign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return
Example #44
0
    def setupWindow(self):
        self.logdebug("Setting up TkAdmin GUI")

        Pmw.initialise(self.window)

        self.window.title(self.title)

        ### Menu ###
        self.__FrameMenu = Frame(self.window)
        self.__FrameMenu.pack(anchor='n', side='top')

        self.__Menu = Menu(self.window)
        self.__MenuFile = Menu(self.__Menu)
        self.__MenuEdit = Menu(self.__Menu)
        self.__MenuMessage = Menu(self.__Menu)
        self.__MenuSettings = Menu(self.__Menu)
        self.__MenuSystem = Menu(self.__Menu)
        self.__Menu.add_cascade(menu=self.__MenuFile, label="File")
        self.__Menu.add_cascade(menu=self.__MenuEdit, label="Edit")
        self.__Menu.add_cascade(menu=self.__MenuMessage, label="Message")
        self.__Menu.add_cascade(menu=self.__MenuSettings, label="Settings")
        self.__Menu.add_cascade(menu=self.__MenuSystem, label="System")
        self.window.config(menu=self.__Menu)

        self.__MenuFile.add_command(label="Update Message Log",
                                    command=self.updateMessageLog)
        self.__MenuFile.add_command(label="Quit", command=self.quit)

        self.autoscan = BooleanVar()
        self.fixsender = BooleanVar()
        self.autoclear = BooleanVar()
        self.showresponses = BooleanVar()

        self.__MenuMessage.add_command(label="View", command=self.showMessage)
        self.__MenuMessage.add_command(label="Compose New",
                                       command=self.composeMessage)

        self.__MenuSettings.add_checkbutton(label="Fix sender",
                                            onvalue=True,
                                            offvalue=False,
                                            variable=self.fixsender)
        self.__MenuSettings.add_checkbutton(label="Autoscan",
                                            onvalue=True,
                                            offvalue=False,
                                            variable=self.autoscan)
        self.__MenuSettings.add_checkbutton(label="Autoclear",
                                            onvalue=True,
                                            offvalue=False,
                                            variable=self.autoclear)
        self.__MenuSettings.add_checkbutton(label="Show responses",
                                            onvalue=True,
                                            offvalue=False,
                                            variable=self.showresponses)

        self.__MenuSystem.add_command(label="View/Edit identity",
                                      command=self.editidentity)
        self.__MenuTemplates = Menu(self.__MenuSystem)
        self.__MenuSystem.add_cascade(label='Create Component',
                                      menu=self.__MenuTemplates)

        self.__MenuNodes = Menu(self.__Menu)
        self.__MenuNodes.add_command(label="Update connected nodes",
                                     command=self.scangateways)
        self.__MenuNodes.add_command(label="Scan Local",
                                     command=self.scanregistry)
        self.__MenuNodes.add_command(label="Dump Nodelist",
                                     command=self.dumpnodelist)

        self.__MenuNodes.add_separator()
        self.__Menu.add_cascade(menu=self.__MenuNodes, label="Nodes")

        ### /Menu ###

        ### Output ###

        self.__FrameOutput = Frame(self.window)
        self.__FrameOutput.pack(side='top', fill='both', expand='yes')

        self.__NotebookOutput = Pmw.NoteBook(self.__FrameOutput)
        self.__NotebookOutput.pack(fill='both', expand=1)

        self.__PageMessages = self.__NotebookOutput.add('Messages')
        self.__PageMap = self.__NotebookOutput.add('Map')
        self.__PageResponses = self.__NotebookOutput.add('Responses')
        #self.__PageLog = self.__NotebookOutput.add('Log') # Needs a loggercomponent and revised logging first

        self.__MessageLog = Pmw.ScrolledListBox(self.__PageMessages)
        self.__MessageLog.pack(expand='yes', fill='both')

        self.__NotebookOutput.tab('Messages').focus_set()

        self.__FrameInput = Frame(self.window, borderwidth=2)
        self.__FrameInput.pack(anchor='s', expand='no', fill='x', side='top')

        self.__FrameStatusbar = Frame(self.window, relief='raised')
        self.__FrameStatusbar.pack(anchor='sw', side='top')  # ,fill='x'

        self.__LabelStatus = Label(self.__FrameStatusbar, text='Ready.')
        self.__LabelStatus.pack(anchor='w', expand='yes',
                                side='top')  # ,fill='both'

        self.__FrameResponses = Frame(self.__PageResponses,
                                      background="yellow")

        self.__FrameResponsesHeader = Frame(self.__FrameResponses)

        self.__LabelResponses = Label(self.__FrameResponsesHeader,
                                      text='Responses')
        self.__LabelResponses.pack(anchor='e', side='right', fill='x')

        self.__ButtonClearResponses = Button(self.__FrameResponsesHeader,
                                             text='Clear')
        self.__ButtonClearResponses.pack(anchor='w', side='left')

        self.__FrameResponsesHeader.pack(anchor='n', fill='x', side=TOP)

        self.__TextResponses = Pmw.ScrolledText(self.__FrameResponses)
        self.__TextResponses.pack(expand=1, fill='both', side=BOTTOM)

        self.__FrameResponses.pack(expand=1, fill="both")

        #self.__FrameLog = Frame(self.__PageLog)
        #self.__FrameLog.pack(side='left', expand=1, fill="both")

        #self.__FrameLogHeader = Frame(self.__FrameLog)
        #self.__FrameLogHeader.pack(anchor='n',expand='yes', fill='x', side='top')

        #self.__LabelLog = Label(self.__FrameLogHeader,text='Log')
        #self.__LabelLog.pack(anchor='e',side='right', fill='both')

        #self.__ButtonClearLog = Button(self.__FrameLogHeader, text='Clear')
        #self.__ButtonClearLog.pack(anchor='w',side='left')

        #self.__TextLog = Pmw.ScrolledText(self.__FrameLog)
        #self.__TextLog.pack(expand=1,fill='both')

        self.__MapCanvas = Canvas(self.__PageMap)
        self.__MapCanvas.pack(expand=1, fill='both')

        self.__NotebookOutput.setnaturalsize()

        ### /Output ###

        ### Input ###

        self.__FrameInputEntry = Frame(self.__FrameInput)

        self.__EntryInput = Entry(self.__FrameInput)
        self.__EntryInput.pack(expand='yes', fill='both', side='left')

        self.__FrameTransmitButton = Frame(self.__FrameInput)
        self.__FrameTransmitButton.pack(anchor='w', side='left')

        self.__ButtonTransmit = Button(self.__FrameTransmitButton,
                                       text='Transmit')
        self.__ButtonTransmit.pack(expand='yes', fill='both', side='top')
        self.__FrameClearButton = Frame(self.__FrameInput)
        self.__FrameClearButton.pack(anchor='w', side='left')
        self.__ButtonClear = Button(self.__FrameClearButton, text='Clear')
        self.__ButtonClear.pack(expand='yes', fill='both', side='top')

        self.__FrameInputEntry.pack(side='left')

        ### /Input ###

        ### Bindings ###

        self.__MessageLog._listbox.bind("<Double-Button-1>", self.showMessage)
        self.__ButtonClearResponses.bind('<ButtonRelease-1>',
                                         self.__on_ButtonClearResponses_Press)
        self.__ButtonTransmit.bind('<ButtonRelease-1>',
                                   self.__on_ButtonTransmit_Release)
        self.__ButtonClear.bind('<ButtonPress-1>', self.__on_ButtonClear_Press)
        self.__EntryInput.bind('<Control-Return>',
                               self.__on_EntryInput_Enter__C)

        self.defaultcolors = {
            'bg': self.window['bg'],
            'fg': self.__EntryInput['fg']
        }
Example #45
0
    def openfile(self, filename=None):
        if filename == None or len(filename) == 0:
            filename = askfilename()
            if len(filename) == 0:
                return
        if not os.path.exists(filename):
            print "cannot find %s" % filename
            return

        self.filename = filename
        w = Toplevel(self.top)
        w.title(os.path.basename(filename))

        ft = Frame(w)
        ft.pack(side='top', fill='x', expand=1)
        dxlabelstr = "%s : select columns to plot" % os.path.basename(filename)
        dx = Label(ft, text=dxlabelstr, font="Helvetica 12 bold")
        dx.pack(side='top', padx=10, pady=10)
        dx2 = Label(ft,
                    text="Use '1' for first data column, '0' for key column",
                    font="Helvetica 10")
        dx2.pack(side='top', padx=10, pady=10)

        textbox = Pmw.ScrolledText(w)
        textbox.pack(side='top', fill='both', expand=1)
        width = int(textbox.component('text').cget('width'))
        height = int(textbox.component('text').cget('height'))

        # see if file has more lines than the window
        wccmd = "wc -l %s" % (filename)
        wc = string.strip(getoutput(wccmd))
        if string.find(wc, " ") > -1:
            wc = string.split(wc)[0]
        wc = int(wc)

        if wc < 2 * height:  # then use entire file
            lines = getoutput("cat %s" % (filename))
            maxwd = 0
            h = string.split(lines, "\n")
            for line in h:
                if len(line) > maxwd:
                    maxwd = len(line)
            if maxwd > width:
                textbox.component('text').configure(width=maxwd)
            textbox.component('text').insert(END, lines)

        else:  # just display the head and tail of the file
            nlines = int(height / 3)
            headcmd = "head -%d %s" % (nlines, filename)
            tailcmd = "tail -%d %s" % (nlines, filename)
            hd = getoutput(headcmd)
            tl = getoutput(tailcmd)
            maxwd = 0
            h = string.split(hd, "\n")
            for line in h:
                if len(line) > maxwd:
                    maxwd = len(line)
            if maxwd > width:
                textbox.component('text').configure(width=maxwd)

            textbox.component('text').insert(END, hd)
            textbox.component('text').insert(END, '\n    :\n')
            for i in range(nlines - 1):
                textbox.component('text').insert(END, '                 :\n')
            textbox.component('text').insert(END, tl)

        fr = Frame(w)
        fr.pack(side='bottom', fill='x', expand=1, padx=5, pady=5)
        xce = Pmw.EntryField(fr,
                             labelpos='w',
                             label_text='column to use for X axis:',
                             value=str(self.xcolumn.get()),
                             validate={'validator': 'numeric'})
        xce.component('entry').configure(textvariable=self.xcolumn)
        yce = Pmw.EntryField(fr,
                             labelpos='w',
                             label_text='column to use for Y axis:',
                             value=str(self.ycolumn.get()),
                             validate={'validator': 'numeric'})
        yce.component('entry').configure(textvariable=self.ycolumn)
        xax = Pmw.EntryField(fr,
                             labelpos='w',
                             label_text='Label for X axis:',
                             value=self.xaxisVar.get())
        xax.component('entry').configure(textvariable=self.xaxisVar)
        yax = Pmw.EntryField(fr,
                             labelpos='w',
                             label_text='Label for Y axis:',
                             value=self.yaxisVar.get())
        yax.component('entry').configure(textvariable=self.yaxisVar)
        xce.grid(row=0, column=0, sticky='w', padx=10, pady=4)
        yce.grid(row=1, column=0, sticky='w', padx=10, pady=4)
        xax.grid(row=0, column=1, sticky='e', padx=10, pady=4)
        yax.grid(row=1, column=1, sticky='e', padx=10, pady=4)

        cancel = IntVar()
        cancel.set(0)

        ok = Button(fr,
                    text='Ok',
                    command=lambda x=w, t='ok': self.okdone(x, t))
        ok.grid(row=2, column=0, sticky='sw', padx=5, pady=5)
        quit = Button(fr,
                      text='Cancel',
                      command=lambda x=w, t='cancel': self.okdone(x, t))
        quit.grid(row=2, column=1, sticky='se', padx=5, pady=5)

        w.lift(self.top)
        self.top.lower(w)
        w.update_idletasks()
        self.top.wait_window(w)
Example #46
0
 def __init__(self, root, q_in, q_out, q_gui):
     self.root = root
     self.q_in = q_in
     self.q_out = q_out
     self.q_gui = q_gui
     
     window = Toplevel(root)
     window.title("Advanced Settings")
     
     s = import_settings()
     
     self.entries = []
     Label(window, text='Saves images to:').pack()
     e = Entry(window, name="image_path")
     t = s.get('image_path')
     if not t: t = ''
     e.insert(0, t)
     e.pack()
     self.imagepath_box = e
     self.entries.append(e)
     Button(window, text = "Browse", command = self.imagepath).pack()
     
     # Front Side Image Configuration #
     self.window_f = Toplevel(root)
     window_f = self.window_f
     window_f.title('Advanced Settings - Frontside Images')
     window_f.protocol("WM_DELETE_WINDOW", self.window_f.withdraw)
     
     Label(window_f, text='Frontside Image Settings').pack()
     settings = [('image_front_prefix', 'Prefix'),
                 ('image_front_postfix', 'Postfix'),
                 ('image_front_fn', 'Naming ["set_incrementer" or "id"]'),
                 ('image_front_delim', 'Delim ["/" for directory structure'),
                 ('image_front_filetype', 'Filetype ["jpg" or "tiff"]'),
                 ('image_front_dpi', 'DPI [150, 300, 600]')]
     
     for setting, label in settings:
         Label(window_f, text=label).pack()
         e = Entry(window_f, name=setting)
         t = s.get(setting)
         if not t: t = ''
         e.insert(0, t)
         e.pack()
         self.entries.append(e)
     
     Button(window_f, text='Save', command=self.save).pack()
     Button(window_f, text='Close', command=self.window_f.withdraw).pack()
     window_f.withdraw()
     # \Front Side Image Configuration #
     
     # Backside image configuration
     self.window_b = Toplevel(root)
     window_b = self.window_b
     window_b.title('Advanced Settings - Backside Images')
     window_b.protocol("WM_DELETE_WINDOW", self.window_b.withdraw)
     
     Label(window_b, text='Backside Image Settings').pack()
     settings = [('image_back_prefix', 'Prefix'),
                 ('image_back_postfix', 'Postfix'),
                 ('image_back_fn', 'Naming ["set_incrementer" or "id"]'),
                 ('image_back_delim', 'Delim ["/" for directory structure'),
                 ('image_back_filetype', 'Filetype ["jpg" or "tiff"]'),
                 ('image_back_dpi', 'DPI [150, 300, 600]')]
     
     for setting, label in settings:
         Label(window_b, text=label).pack()
         e = Entry(window_b, name=setting)
         t = s.get(setting)
         if not t: t = ''
         e.insert(0, t)
         e.pack()
         self.entries.append(e)
         
     Button(window_b, text='Save', command=self.save).pack()
     Button(window_b, text='Close', command=self.window_b.withdraw).pack()
     window_b.withdraw()
     # \Backside
     
     # Robot Options
     self.window_o = Toplevel(root)
     window_o = self.window_o
     window_o.title('Advanced Settings - Robot Options')
     window_o.protocol("WM_DELETE_WINDOW", self.window_o.withdraw)
     
     settings = [('arm_home_value', 'arm_home_value'),
                 ('arm_in_value', 'arm_in_value'),
                 ('arm_out_value', 'arm_out_value'),
                 ('actuator_home_value', 'actuator_home_value'),
                 ('actuator_up_value', 'actuator_up_value'),
                 ('baudrate', 'baudrate'),
                 ('gado_port', 'gado_port')]
     
     for setting, label in settings:
         Label(window_o, text=label).pack()
         e = Entry(window_o, name=setting)
         t = s.get(setting)
         if not t: t = ''
         e.insert(0, t)
         e.pack()
         self.entries.append(e)
     
     Button(window_o, text='Save', command=self.save).pack()
     Button(window_o, text='Close', command=self.window_o.withdraw).pack()
     window_o.withdraw()
     # \Backside
     
     #Logging Options
     self.window_l = Toplevel(root)
     window_l = self.window_l
     window_l.title('Logging Settings')
     window_l.protocol("WM_DELETE_WINDOW", self.window_l.withdraw)
     
     Label(window_l, text='Desired Logging Level:').pack()
     self.level_selection = Pmw.ComboBox(window_l, selectioncommand=lambda val: self._updateDebugLevel(self.level_selection.get()))
     self.level_selection.pack()
     
     #Populate combobox with different loglevels
     self._populateLevelComboBox()
     self.level_selection.selectitem(0)
     
     self.logLevelEntry = Entry(window_l, name="log_level")
     
     #e = self.level_selection.get()
     
     self.entries.append(self.logLevelEntry)
     
     settings = [('log_level', 'log_level'),]
     
         
     Button(window_l, text='Save', command=self.save).pack()
     Button(window_l, text='Close', command=self.window_l.withdraw).pack()
     window_l.withdraw()
     
     # Misc Options
     self.window_m = Toplevel(root)
     window_m = self.window_m
     window_m.title('Advanced Settings - Misc Settings')
     window_m.protocol("WM_DELETE_WINDOW", self.window_m.withdraw)
     
     Label(window_m, text='Miscellaneous Settings').pack()
     Label(window_m, text='Saves database to:').pack()
     e = Entry(window_m, name="db_directory")
     e.pack()
     self.dbpath_box = e
     self.entries.append(e)
     Button(window_m, text = "Browse", command = self.dbpath).pack()
     
     settings = [('scanner_name', 'Scanner Name'),
                 ('webcam_name', 'Webcam Name'),]
     
     for setting, label in settings:
         Label(window_m, text=label).pack()
         e = Entry(window_m, name=setting)
         t = s.get(setting)
         if not t: t = ''
         e.insert(0, t)
         e.pack()
         self.entries.append(e)
     
     Button(window_m, text='Save', command=self.save).pack()
     Button(window_m, text='Close', command=self.window_m.withdraw).pack()
     window_m.withdraw()
     # \Misc Options
     
     
     self.window = window
     window.protocol("WM_DELETE_WINDOW", self.window.withdraw)
     
     Button(window, text='Frontside Image Settings', command=self.window_f.deiconify).pack()
     Button(window, text='Backside Image Settings', command=self.window_b.deiconify).pack()
     Button(window, text='Robot Options', command=self.window_o.deiconify).pack()
     Button(window, text='Misc Settings', command=self.window_m.deiconify).pack()
     Button(window, text='Logging Options', command=self.window_l.deiconify).pack()
     Button(window, text='Save', command=self.save).pack()
     Button(window, text='Close', command=self.window.withdraw).pack()
     
     window.withdraw()
Example #47
0
    def __init__(self, levelEditor, visGroups=['None'], parent=None, **kw):

        INITOPT = Pmw.INITOPT
        optiondefs = (('title', 'Visability Groups Editor', None), )
        self.defineoptions(kw, optiondefs)

        Pmw.MegaToplevel.__init__(self, parent, title=self['title'])
        if sys.platform == 'win32':
            # FIXME: This doesn't work in other platforms for some reason...
            self.iconbitmap("resources/openttle_ico_temp.ico")
        self.levelEditor = levelEditor
        self.visGroups = visGroups
        self.visGroupNames = [pair[1].getName() for pair in self.visGroups]
        # Initialize dictionary of visibility relationships
        self.visDict = {}
        # Group we are currently setting visGroups for
        self.target = None
        # Flag to enable/disable toggleVisGroup command
        self.fCommand = 1

        # Handle to the toplevels hull
        hull = self.component('hull')

        balloon = self.balloon = Pmw.Balloon(hull)
        # Start with balloon help disabled
        self.balloon.configure(state='none')

        menuFrame = Frame(hull, relief=GROOVE, bd=2)
        menuFrame.pack(fill=X, expand=1)

        menuBar = Pmw.MenuBar(menuFrame, hotkeys=1, balloon=balloon)
        menuBar.pack(side=LEFT, expand=1, fill=X)
        menuBar.addmenu('Vis Groups Editor',
                        'Visability Groups Editor Operations')
        menuBar.addmenuitem('Vis Groups Editor',
                            'command',
                            'Exit Visability Groups Editor',
                            label='Exit',
                            command=self.preDestroy)

        menuBar.addmenu('Help', 'Visability Groups Editor Help Operations')
        self.toggleBalloonVar = IntVar()
        self.toggleBalloonVar.set(0)
        menuBar.addmenuitem('Help',
                            'checkbutton',
                            'Toggle balloon help',
                            label='Balloon Help',
                            variable=self.toggleBalloonVar,
                            command=self.toggleBalloon)

        # Create a combo box to choose target vis group
        self.targetSelector = Pmw.ComboBox(
            hull,
            labelpos=W,
            label_text='Target Vis Group:',
            entry_width=12,
            selectioncommand=self.selectVisGroup,
            scrolledlist_items=self.visGroupNames)
        self.targetSelector.selectitem(self.visGroupNames[0])
        self.targetSelector.pack(expand=1, fill=X)

        # Scrolled frame to hold radio selector
        sf = Pmw.ScrolledFrame(hull,
                               horizflex='elastic',
                               usehullsize=1,
                               hull_width=200,
                               hull_height=400)
        frame = sf.interior()
        sf.pack(padx=5, pady=3, fill=BOTH, expand=1)

        # Add vis groups selector
        self.selected = Pmw.RadioSelect(frame,
                                        selectmode=MULTIPLE,
                                        orient=VERTICAL,
                                        pady=0,
                                        command=self.toggleVisGroup)
        for groupInfo in self.visGroups:
            nodePath = groupInfo[0]
            group = groupInfo[1]
            name = group.getName()
            self.selected.add(name, width=12)
            # Assemble list of groups visible from this group
            visible = []
            for i in range(group.getNumVisibles()):
                visible.append(group.getVisibleName(i))
            visible.sort()
            self.visDict[name] = [nodePath, group, visible]
        # Pack the widget
        self.selected.pack(expand=1, fill=X)
        # And make sure scrolled frame is happy
        sf.reposition()

        buttonFrame = Frame(hull)
        buttonFrame.pack(fill=X, expand=1)

        self.showMode = IntVar()
        self.showMode.set(0)
        self.showAllButton = Radiobutton(buttonFrame,
                                         text='Show All',
                                         value=0,
                                         indicatoron=1,
                                         variable=self.showMode,
                                         command=self.refreshVisibility)
        self.showAllButton.pack(side=LEFT, fill=X, expand=1)
        self.showActiveButton = Radiobutton(buttonFrame,
                                            text='Show Target',
                                            value=1,
                                            indicatoron=1,
                                            variable=self.showMode,
                                            command=self.refreshVisibility)
        self.showActiveButton.pack(side=LEFT, fill=X, expand=1)

        # Make sure input variables processed
        self.initialiseoptions(VisGroupsEditor)

        # Switch to current target's list
        self.selectVisGroup(self.visGroupNames[0])
Example #48
0
    def mkmenu(self, master):
        menuBar = Pmw.MenuBar(master, hull_relief='raised', hull_borderwidth=1)
        menuBar.pack(fill='x')

        # Make the File menu
        menuBar.addmenu('File', 'helptxt')
        menuBar.addmenuitem('File',
                            'command',
                            'open file',
                            label='Open',
                            command=self.openfile)
        menuBar.addmenuitem('File', 'separator')
        menuBar.addmenuitem('File',
                            'command',
                            'quit',
                            label='Quit',
                            command=master.quit)
        # Make the Option menu
        menuBar.addmenu('Options', '')
        menuBar.addmenuitem('Options',
                            'checkbutton',
                            'turn zoom on/off',
                            label='Magnify',
                            variable=self.magnifyVar,
                            command=self.magnifyOn)
        menuBar.addmenuitem('Options',
                            'command',
                            'Reset magnification',
                            label='Reset view',
                            command=self.magReset)
        menuBar.addmenuitem('Options',
                            'command',
                            'change symbols',
                            label='Symbols',
                            command=self.symbolsMenu)
        # Make the Region menu
        menuBar.addmenu('Regions', '')
        menuBar.addmenuitem('Regions',
                            'checkbutton',
                            'polygon draw',
                            label='Polygon select',
                            variable=self.polygonVar,
                            command=self.polygonOn)
        menuBar.addmenuitem('Regions',
                            'command',
                            'save selected area',
                            label='Save selected polygon',
                            command=self.savePolygon)
        menuBar.addmenuitem('Regions',
                            'command',
                            'delete selected area',
                            label='Delete selected polygon',
                            command=self.deletePolygon)

        # Magnify, Region Buttons
        self.magButton = Button(menuBar.component('hull'),
                                text="Magnifier",
                                command=self.magnifyOn)
        self.magButton.pack(side='left', padx=10, pady=10)
        self.magButton.bind('<Double-Button-1>', self.magReset)
        self.polyButton = Button(menuBar.component('hull'),
                                 text="Region select",
                                 command=self.polygonOn)
        self.polyButton.pack(side='left', padx=10, pady=10)

        self.backgroundcolor = self.magButton.cget('background')
        self.activebackgroundcolor = self.magButton.cget('activebackground')

        # Make the Help menu
        menuBar.addmenu('Help', '', side='right')
        menuBar.addmenuitem('Help',
                            'command',
                            'view help page',
                            label='Help',
                            command=self.help)
        menuBar.addmenuitem('Help',
                            'command',
                            'about this program',
                            label='About',
                            command=self.about)
Example #49
0
        menuBar.addmenuitem('Run Control', 'separator')
        menuBar.addmenuitem('Run Control',
                            'command',
                            'Close the GUI',
                            command=Quit,
                            label='Quit')

        mainPart = Tkinter.Label(parent,
                                 text='GUI',
                                 background='white',
                                 foreground='white',
                                 padx=100,
                                 pady=100)
        mainPart.pack(fill='both', expand=1)

        buttonBox = Pmw.ButtonBox(parent)
        buttonBox.pack(fill='x')
        buttonBox.add('Start\nRoot', command=Print('start root'))

        self.menuBar = menuBar
        self.mainPart = mainPart
        self.buttonBox = buttonBox


if __name__ == '__main__':
    root = Tkinter.Tk()
    parent = Pmw.initialise(root)
    root.title('pCT GUI')
    derp = mainWindow(root)
    root.mainloop()
Example #50
0
    x = -1
    y = -1

    if length > 0:
        filename = sys.argv[1]
        if filename == '-h' or filename == '-help':
            printHelp()
            sys.exit()
        if not os.path.exists(filename):
            print "cannot find file %s" % filename
            sys.exit()
    if length > 2:
        try:
            x = int(sys.argv[2])
            y = int(sys.argv[3])
        except:
            printHelp()
            sys.exit()

    master = Tk()
    Pmw.initialise(master, fontScheme='pmw1')
    master.title("scatter plot")

    if x > -1 and y > -1:
        c = scatter(master, filename, xcol=x, ycol=y)
    else:
        c = scatter(master, filename)

    master.mainloop()
Example #51
0
def plugin_info_dialog(parent, info):
    '''
    Shows a popup with plugin info (name, metadata, doc-string, ...)
    '''
    dialog = Pmw.MegaToplevel(parent, title='Info about plugin ' + info.name)
    grid = dialog.interior()

    highlighted_labels = ['Citation', 'Citation-Required']

    bg_important = '#ff6666'
    bg_notice = '#ffff99'

    def add_line(label, text):
        bg = None
        if label in highlighted_labels:
            bg = bg_important
        row = grid.grid_size()[1]
        Tkinter.Label(grid, text=label + ':', bg=bg).grid(row=row,
                                                          column=0,
                                                          sticky='nw',
                                                          padx=5,
                                                          pady=2)
        e = Tkinter.Entry(grid)
        e.insert(0, str(text))
        e.config(state='readonly')
        e.grid(row=row, column=1, sticky='nwe', padx=5, pady=2)

    if info.get_citation_required():
        Tkinter.Label(
            grid,
            text='This Plugin requires a citation. See below for details.',
            bg=bg_important,
            padx=10,
            pady=10).grid(columnspan=2, sticky='nesw')

    add_line('Name', info.name)
    if not info.is_temporary:
        add_line('Python Module Name', info.mod_name)
        add_line('Filename', info.filename)
    grid.columnconfigure(1, weight=1)

    metadata = info.get_metadata()
    for label, value in metadata.iteritems():
        add_line(label, value)

    if not info.is_temporary:
        if not info.loaded:
            Tkinter.Label(
                grid,
                text=
                'more information might be available after plugin is loaded',
                bg=bg_notice,
                padx=10,
                pady=10).grid(columnspan=2, sticky='nesw')
        else:
            add_line('commands', ', '.join(info.commands))

    docstring = info.get_docstring()
    if docstring is not None:
        st = Pmw.ScrolledText(grid, text_wrap='none', text_padx=4, text_pady=4)
        st.appendtext(docstring.strip())
        st.configure(text_state='disabled')
        st.grid(columnspan=2, sticky='nesw', padx=5, pady=2)
        grid.rowconfigure(grid.grid_size()[1] - 1, weight=1)
    elif info.loaded or info.is_temporary:
        Tkinter.Label(grid,
                      text='no documentation available',
                      bg=bg_notice,
                      padx=10,
                      pady=10).grid(columnspan=2, sticky='nesw')
Example #52
0
    def __init__(self, parent):
        self.parent = parent
        self.balloon = Pmw.Balloon(parent)

        def Quit():
            root.destroy()

        menuBar = Pmw.MenuBar(parent,
                              hull_relief='raised',
                              hull_borderwidth=1,
                              balloon=self.balloon)
        menuBar.pack(fill='x')

        menuBar.addmenu(
            'Run Control',
            'Calibration,Download Configuration,Number of Triggers,Data Output File,Upload Configuration,Start DAQ,Quit'
        )
        menuBar.addcascademenu('Run Control',
                               'Calibration',
                               'View and/or change the calibration',
                               traverseSpec='z',
                               tearoff=1)
        menuBar.addmenuitem('Calibration',
                            'command',
                            'Display the DAC calibration',
                            command=Print('display the DAC calibration'),
                            label='Display DAC Calibration')

        menuBar.addmenuitem('Calibration',
                            'command',
                            'Display the calibration mask',
                            command=Print('display the calibration mask'),
                            label='Display Calibration Mask')
        menuBar.addmenuitem('Calibration',
                            'command',
                            'Change the DAC calibration',
                            command=Print('change the DAC calibration'),
                            label='Change DAC Calibration')
        menuBar.addmenuitem('Calibration',
                            'command',
                            'Change the calibration mask',
                            command=Print('change the calibration mask'),
                            label='Change Calibration Mask')

        menuBar.addmenuitem('Run Control',
                            'command',
                            'Download a configuration',
                            command=Print('download configuration'),
                            label='Download Configuration')

        menuBar.addmenuitem('Run Control',
                            'command',
                            'Set the number of triggers',
                            command=Print('set number of triggers'),
                            label='Number of Triggers')
        menuBar.addmenuitem('Run Control',
                            'command',
                            'Change the file where the data will be sent to',
                            command=Print('set data output file'),
                            label='Data Output File')
        menuBar.addmenuitem('Run Control',
                            'command',
                            'Upload a configuration',
                            command=Print('upload a configuration'),
                            label='Upload Configuration')

        menuBar.addmenuitem('Run Control',
                            'command',
                            'Start the data aquisition',
                            command=Print('start data aquisition'),
                            label='Start DAQ')
        menuBar.addmenuitem('Run Control', 'separator')
        menuBar.addmenuitem('Run Control',
                            'command',
                            'Close the GUI',
                            command=Quit,
                            label='Quit')

        mainPart = Tkinter.Label(parent,
                                 text='GUI',
                                 background='white',
                                 foreground='white',
                                 padx=100,
                                 pady=100)
        mainPart.pack(fill='both', expand=1)

        buttonBox = Pmw.ButtonBox(parent)
        buttonBox.pack(fill='x')
        buttonBox.add('Start\nRoot', command=Print('start root'))

        self.menuBar = menuBar
        self.mainPart = mainPart
        self.buttonBox = buttonBox
Example #53
0
    def page_install_new(self, notebook):
        from pymol import Scratch_Storage

        page = notebook.add('Install New Plugin')

        # local file

        def c_local():
            from .legacysupport import installPlugin, get_pmgapp
            installPlugin(get_pmgapp())
            self.f_installed.reload()

        w = Pmw.Group(page, tag_text='Install from local file')
        w.pack(**default_top)

        b_local = Tkinter.Button(w.interior(),
                                 text='Choose file...',
                                 command=c_local)
        b_local.pack(side='left', **default_pad)

        if confirm_network_access.ok < 0:
            Tkinter.Label(
                page, text='Network access has been disabled').pack(expand=1)
            return

        # pymolwiki

        def fetchplugin():
            if not confirm_network_access():
                return

            from .installation import installPluginFromFile
            from .repository import fetchscript
            url = e_wiki.get()
            if not len(url):
                return
            import tempfile, shutil
            tmpdir = tempfile.mkdtemp()
            filename = fetchscript(url, tmpdir, False)
            if filename:
                installPluginFromFile(filename, self.interior())
            shutil.rmtree(tmpdir)
            self.f_installed.reload()

        w = Pmw.Group(page, tag_text='Install from PyMOLWiki')
        w.pack(**default_top)
        w = w.interior()

        l_repo = Tkinter.Label(
            w,
            text='Paste a PyMOLWiki url, the page will be downloaded and '
            'scanned for scripts that extend the PyMOL API',
            justify='left',
            anchor='w',
            wraplength=500)
        l_repo.pack(**default_top)

        e_wiki = Pmw.EntryField(w,
                                labelpos='w',
                                label_text='URL:',
                                command=fetchplugin)
        e_wiki.pack(side='left', fill='x', expand=1, **default_pad)
        b_wiki = Tkinter.Button(w, text='Fetch', command=fetchplugin)
        b_wiki.pack(side='right', **default_pad)

        # repository

        w = Pmw.Group(page, tag_text='Install from Repository')
        w.pack(fill='both', **default_pad)

        pw = Pmw.PanedWidget(w.interior(), orient='horizontal')

        pane_left = pw.add('left', min=.2)
        pane_right = pw.add('right', min=.2, max=.5)

        repo_tmp = Scratch_Storage()

        def selecmd_left():
            '''
            Get plugins listing for selected repository.
            '''
            if not confirm_network_access():
                return

            from .repository import guess
            sels = slb_left.getcurselection()
            if len(sels) == 0:
                slb_right.setlist(['- empty -'])
                return
            try:
                url = sels[0]
                repo_tmp.r = guess(url)
                slb_right.setlist(repo_tmp.r.list())
            except:
                slb_right.setlist(['- listing failed -'])

        def infocmd_right():
            '''
            Download file, parse for metadata, show info-popup and delete file
            '''
            from . import PluginInfo
            from .installation import get_name_and_ext, extract_zipfile, zip_extensions
            sels = slb_right.getcurselection()
            if len(sels) == 0:
                return
            import tempfile, shutil, os
            tmpdir = tempfile.mkdtemp()
            tmpdirs = [tmpdir]
            try:
                name = sels[0]
                repo_tmp.r.copy(name, tmpdir)
                filename = os.path.join(tmpdir, name)
                name, ext = get_name_and_ext(filename)
                if ext in zip_extensions:
                    tmpdir, dirnames = extract_zipfile(filename, ext)
                    tmpdirs.append(tmpdir)
                    name = dirnames[-1]
                    filename = os.path.join(os.path.join(tmpdir, *dirnames),
                                            '__init__.py')
                info = PluginInfo(name, filename)
                plugin_info_dialog(self.interior(), info)
            except:
                tkMessageBox.showinfo('Error', 'Could not get plugin info')
            finally:
                for tmpdir in tmpdirs:
                    shutil.rmtree(tmpdir)

        def selecmd_right():
            '''
            Download plugin from repository and install it.
            '''
            from .installation import installPluginFromFile
            sels = slb_right.getcurselection()
            if len(sels) == 0:
                return
            import tempfile, shutil, os
            tmpdir = tempfile.mkdtemp()
            try:
                name = sels[0]
                repo_tmp.r.copy(name, tmpdir)
                filename = os.path.join(tmpdir, name)
                installPluginFromFile(filename, self.interior())
            except:
                tkMessageBox.showinfo('Error', 'Could not install plugin')
            finally:
                shutil.rmtree(tmpdir)
            self.f_installed.reload()

        slb_left = Pmw.ScrolledListBox(
            pane_left,
            items=(
                'http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/',
                'https://github.com/Pymol-Scripts/Pymol-script-repo',

                # for testing
                'http://www.thomas-holder.de/projects/pymol/repository/',
            ),
            listbox_height=30,
            labelpos='nw',
            label_text='Repositories',
            selectioncommand=selecmd_left)

        slb_right = Pmw.ScrolledListBox(
            pane_right,
            items=(),
            listbox_height=30,
            labelpos='nw',
            label_text='Items',
        )

        repo_bb_left = Pmw.ButtonBox(pane_left)
        repo_bb_right = Pmw.ButtonBox(pane_right)

        def dummy_command():
            showinfo = tkMessageBox.showinfo
            showinfo('Dummy', 'Not implemented', parent=self.interior())

        repo_bb_left.add('Add ...', command=dummy_command)
        repo_bb_left.add('Remove', command=dummy_command)
        repo_bb_right.add('Info', command=infocmd_right)
        repo_bb_right.add('Install', command=selecmd_right)

        repo_bb_left.pack(
            side='bottom',
            fill='x',
        )
        repo_bb_right.pack(
            side='bottom',
            fill='x',
        )

        slb_left.pack(fill='both', **default_pad)
        slb_right.pack(fill='both', **default_pad)
        pw.pack(fill='both')
Example #54
0
def mainDialog(root=None):
    """ Creates the GUI """
    global entry_vdw, entry_elec, entry_conformers, entry_lowest
    def set_minimize():
        forcefield = ff_value.get()
        method = method_value.get()
        nsteps0 = int(entry_nsteps0.get())
        conv = float(entry_conv.get())
        cutoff = bool(cutoff_value.get())
        cut_vdw = float(entry_vdw.get())
        cut_elec = float(entry_elec.get())
        selection = sel0_value.get()
        minimize(selection, forcefield, method, nsteps0, conv, cutoff, cut_vdw, cut_elec)

    def set_conf_search():
        forcefield = ff_value.get()
        conf_method = conf_method_value.get()
        nsteps1 = int(entry_nsteps1.get())
        conformers = int(entry_conformers.get())
        lowest_conf = int(entry_lowest.get())
        selection = sel1_value.get()
        conf_search(selection, forcefield, conf_method, nsteps1, conformers, lowest_conf)


    master = Toplevel(root)
    master.title(' Optimize ')
    w = Tkinter.Label(master, text="\nOptimize: Let's find that minimum!\n",
                                background = 'black',
                                foreground = 'white')
    w.pack(expand=1, fill = 'both', padx=4, pady=4)
############################ NoteBook #########################################
    Pmw.initialise()
    nb = Pmw.NoteBook(master, hull_width=430, hull_height=320)
    p1 = nb.add(' Local optimization ')
    p2 = nb.add(' Global Optimization ')
    p3 = nb.add('    About   ')
    nb.pack(padx=5, pady=5, fill=BOTH, expand=1)
############################ Minimization TAB #################################
    group = Pmw.Group(p1, tag_text='Minimization options')
    group.pack(fill='both', expand=1, padx=5, pady=5)
# Force Field options
    ff_value = StringVar(master=group.interior())
    ff_value.set('MMFF94s')
    Pmw.OptionMenu(group.interior(),
                labelpos = 'w',
                label_text = 'Force Field',
                menubutton_textvariable = ff_value,
                items = ['GAFF', 'MMFF94s', 'MMFF94', 'UFF', 'Ghemical'],
                menubutton_width = 15,
        ).grid(row=0, columnspan=2)
# Method
    method_value = StringVar(master=group.interior())
    method_value.set('Conjugate Gradients')
    Pmw.OptionMenu(group.interior(),
                labelpos = 'w',
                label_text = '   Method  ',
                menubutton_textvariable = method_value,
                items = ['Conjugate Gradients', 'Steepest Descent'],
                menubutton_width = 15,
        ).grid(row=1, columnspan=2)
    Label(group.interior(), text='steps').grid(row=2, column=0)
    nsteps0 = StringVar(master=group.interior())
    nsteps0.set(500)
    entry_nsteps0 = Entry(group.interior(), textvariable=nsteps0, width=15)
    entry_nsteps0.grid(row=2, column=1)
    entry_nsteps0.update()
    Label(group.interior(), text='convergence').grid(row=3, column=0)
    conv = StringVar(master=group.interior())
    conv.set(0.0001)
    entry_conv = Entry(group.interior(), textvariable=conv, width=15)
    entry_conv.grid(row=3, column=1)
    entry_conv.update()
    Label(group.interior(), text='selection').grid(row=4, column=0)
    sel0_value = StringVar(master=group.interior())
    names = cmd.get_names('all')
    if len(names) > 0:
        sel0_value.set(names[0])
    else:
        sel0_value.set('all')
    entry_sel0_value = Entry(group.interior(),textvariable=sel0_value, width=15)
    entry_sel0_value.grid(row=4, column=1)
    entry_sel0_value.configure(state='normal')
    entry_sel0_value.update()
###########################################################################
    cutoff_value = BooleanVar(master=group.interior())
    cutoff_value.set(False)
    Radiobutton(group.interior(), text='No cutoff ', variable=cutoff_value, value=False, command=disable_entry).grid(row=5, columnspan=3)
    Radiobutton(group.interior(), text='Use cutoff', variable=cutoff_value, value=True,
command=enable_entry).grid(row=6, columnspan=3)
    Label(group.interior(), text='Van der Waals').grid(row=7, column=0)
    vdw_value = StringVar(master=group.interior())
    vdw_value.set(6.0)
    entry_elec = Entry(group.interior(),textvariable=vdw_value, width=15)
    entry_elec.grid(row=7, column=1)
    entry_elec.configure(state='disabled')
    entry_elec.update()
    Label(group.interior(), text='Electrostatic').grid(row=8, column=0)
    elec_value = StringVar(master=group.interior())
    elec_value.set(8.0)
    entry_vdw = Entry(group.interior(),textvariable=elec_value, width=15)
    entry_vdw.grid(row=8, column=1)
    entry_vdw.configure(state='disabled')
    entry_vdw.update()

# Run
    Button(p1, text="Minimize", command=set_minimize).pack(side=BOTTOM)
############################ Conformation search TAB ###########################
    group = Pmw.Group(p2,tag_text='Conformational Search options')
    group.pack(fill='both', expand=1, padx=5, pady=5)
# Force Field options
    ff_value = StringVar(master=group.interior())
    ff_value.set('MMFF94s')
    Pmw.OptionMenu(group.interior(),
                labelpos = 'w',
                label_text = 'Force Field',
                menubutton_textvariable = ff_value,
                items = ['GAFF', 'MMFF94s', 'MMFF94', 'UFF', 'Ghemical'],
                menubutton_width = 15,
        ).grid(row=0, columnspan=2)
# Method
    conf_method_value = StringVar(master=group.interior())
    conf_method_value.set('Weighted')
    Pmw.OptionMenu(group.interior(),
                labelpos = 'w',
                label_text = '   Method  ',
                menubutton_textvariable = conf_method_value,
                items = ['Weighted', 'Random', 'Systematic'],
                menubutton_width = 15,
                command = enable_disable_entry,
        ).grid(row=1, columnspan=2)
    Label(group.interior(), text='steps').grid(row=2, column=0)
    nsteps1 = StringVar(master=group.interior())
    nsteps1.set(500)
    entry_nsteps1 = Entry(group.interior(), textvariable=nsteps1, width=15)
    entry_nsteps1.grid(row=2, column=1)
    entry_nsteps1.update()
    Label(group.interior(), text='conformers ').grid(row=3, column=0)
    conformers = StringVar(master=group.interior())
    conformers.set(25)
    entry_conformers = Entry(group.interior(), textvariable=conformers, width=15)
    entry_conformers.grid(row=3, column=1)
    entry_conformers.configure(state='normal')
    entry_conformers.update()
    Label(group.interior(), text=' lowest conf    ').grid(row=4, column=0)
    lowest = StringVar(master=group.interior())
    lowest.set(5)
    entry_lowest = Entry(group.interior(), textvariable=lowest, width=15)
    entry_lowest.grid(row=4, column=1)
    entry_lowest.configure(state='normal')
    entry_lowest.update()
    Label(group.interior(), text='selection').grid(row=5, column=0)
    sel1_value = StringVar(master=group.interior())
    names = cmd.get_names('all')
    if len(names) > 0:
        sel1_value.set(names[0])
    else:
        sel1_value.set('all')
    entry_sel1_value = Entry(group.interior(),textvariable=sel1_value, width=15)
    entry_sel1_value.grid(row=5, column=1)
    entry_sel1_value.configure(state='normal')
    entry_sel1_value.update()
# Run
    Button(p2, text="Search", command=set_conf_search).pack(side=BOTTOM)
############################ About TAB ########################################
    Label(p3, text = """
Optimize provides a PyMOL graphical interface to some 
of the many options available in openbabel (openbabel.org).
If you find Optimize useful great! 
If you don't and have some suggestions or comments 
to do please write to me ([email protected]).
""",justify=CENTER).pack()
Example #55
0
    def main(self):
        root = Tk()
        root.title('ASTRI')
        Pmw.initialise(root)
        root.geometry('{}x{}'.format(400, 150))
        choice = None

        self.target = Label(
            root,
            relief='sunken',
            padx=20,
            pady=20,
        )

        fm1 = Frame(root)
        fm2 = Frame(root)
        fm3 = Frame(root)
        fm4 = Frame(root)
        fm5 = Frame(root)

        ports = parase.serial_ports()
        combobox = Pmw.ComboBox(fm1,
                                label_text='Select Serial Port:',
                                labelpos='we',
                                listbox_width=10,
                                dropdown=1,
                                selectioncommand=self.choseEntry,
                                scrolledlist_items=ports)
        combobox.pack(side=TOP)
        first = ports[0]
        combobox.selectitem(first)  #select com port
        self.choseEntry(first)

        label_text = ''
        for i in range(0, 2):
            if i == 0:
                for j in range(1, 9):
                    label_text = 'LED0'
                    label_text += str(j)
                    setattr(var, label_text, IntVar())
                    if j < 5:
                        Checkbutton(fm2,
                                    text=label_text,
                                    state=NORMAL,
                                    anchor=W,
                                    command=lambda x=j: self.onclick(x),
                                    variable=getattr(var, label_text)).grid(
                                        row=i, column=j, sticky=W)
                        #Checkbutton.bind("<button-1>", self.onclick(j))
                    else:
                        Checkbutton(fm3,
                                    text=label_text,
                                    state=NORMAL,
                                    anchor=W,
                                    command=lambda x=j: self.onclick(x),
                                    variable=getattr(var, label_text)).grid(
                                        row=i, column=j, sticky=W)
                        #Checkbutton.bind("<button-1>", self.onclick(j))
            else:
                for j in range(9, 17):
                    if j < 10:
                        label_text = 'LED0'
                        label_text += str(j)
                        setattr(var, label_text, IntVar())
                        Checkbutton(fm4,
                                    text=label_text,
                                    state=NORMAL,
                                    anchor=W,
                                    command=lambda x=j: self.onclick(x),
                                    variable=getattr(var, label_text)).grid(
                                        row=i, column=j - 9, sticky=W)
                        #Checkbutton.bind("<button-1>", self.onclick(j))
                    else:
                        label_text = 'LED'
                        label_text += str(j)
                        setattr(var, label_text, IntVar())
                        if j < 13:
                            Checkbutton(fm4,
                                        text=label_text,
                                        state=NORMAL,
                                        anchor=W,
                                        command=lambda x=j: self.onclick(x),
                                        variable=getattr(var,
                                                         label_text)).grid(
                                                             row=i,
                                                             column=j - 9,
                                                             sticky=W)
                        else:
                            Checkbutton(fm5,
                                        text=label_text,
                                        state=NORMAL,
                                        anchor=W,
                                        command=lambda x=j: self.onclick(x),
                                        variable=getattr(var,
                                                         label_text)).grid(
                                                             row=i,
                                                             column=j - 9,
                                                             sticky=W)

        fm1.pack(side=TOP, expand=NO)
        fm2.pack(side=TOP, expand=NO)
        fm3.pack(side=TOP, expand=NO)
        fm4.pack(side=TOP, expand=NO)
        fm5.pack(side=TOP, expand=NO)
        root.mainloop()
Example #56
0
    def page_settings(self, notebook):
        page = notebook.add('Settings')

        from . import get_startup_path, set_startup_path

        # plugin search path
        w = Pmw.Group(page, tag_text='Plugin search path')
        w.pack(**default_top)

        def slb_path_setlist(items):
            set_startup_path(items)
            slb_path.setlist(items)
            self.b_save.configure(background='red')

        def slb_path_add():
            import os
            from .installation import get_default_user_plugin_path as userpath
            d = tkFileDialog.askdirectory(initialdir=userpath(),
                                          parent=self.interior())
            if not len(d):
                return
            if not os.path.exists(d):
                os.makedirs(d)
            items = list(slb_path.get())
            items.append(d)
            slb_path_setlist(items)
            slb_path.setvalue([d])  # provide list to avoid unicode problem

        def slb_path_remove():
            v = slb_path.getvalue()
            items = list(slb_path.get())
            for item in v:
                items.remove(item)
            slb_path_setlist(items)

        def slb_path_move(j=1):
            v = slb_path.getvalue()
            if len(v) == 0:
                return
            items = list(slb_path.get())
            i = items.index(v[0])
            if not (0 <= i + j < len(items)):
                return
            items.pop(i)
            items.insert(i + j, v[0])
            slb_path_setlist(items)
            slb_path.setvalue([v[0]])  # provide list to avoid unicode problem

        slb_path = Pmw.ScrolledListBox(w.interior(),
                                       items=get_startup_path(),
                                       listbox_height=4)
        slb_path.setvalue([slb_path.get(0)
                           ])  # provide list to avoid unicode problem
        slb_path.pack(**default_top)

        bb_path = Pmw.ButtonBox(w.interior())
        bb_path.add('Add new directory...', command=slb_path_add)
        bb_path.add('Remove', command=slb_path_remove)
        bb_path.add('Move up', command=lambda: slb_path_move(-1))
        bb_path.add('Move down', command=slb_path_move)
        bb_path.pack(side='top', fill='x')

        l_path = Tkinter.Label(
            w.interior(),
            text=
            'PyMOL restart required in order to find plugins in modified plugin search path'
        )
        l_path.pack(**default_top)

        w = Pmw.Group(page, tag_text='Preferences (Read-Only)')
        w.pack(**default_top)
        w = w.interior()

        from . import preferences
        for row, key in enumerate(preferences):
            value = str(preferences[key])
            if len(value) > 100:
                value = value[:97] + '...'
            Tkinter.Label(w, text=key).grid(row=row,
                                            column=0,
                                            sticky='nw',
                                            padx=3,
                                            pady=2)
            e = Tkinter.Entry(w)
            e.insert(0, value)
            e.config(state='readonly')
            e.grid(row=row, column=1, sticky='nwe', padx=5, pady=2)
        w.columnconfigure(1, weight=1)
Example #57
0
  def __init__(self,parent,filename):
    self.parent=parent
    self.modelName=""
    self.modelType=""
    self.modelList=[]
    self.click_result=""	
    
  # Collect model information from the circuit file
    try:
      self.FreeEDA_HOME=FreeEDA_HOME
    except NameError:
      try:
        self.FreeEDA_HOME=os.environ["FreeEDA_HOME"]
      except KeyError:
        tkMessageBox.showerror("Error FreeEDA_HOME is not set","Please set FreeEDA_HOME variable in .bashrc\n\nStep to set  FreeEDA_HOME variable:\n  1) Open ~/.bashrc using text editor (vi ~/.bash).\n   2) Add the line \"Export FreeEDA_HOME=<path_of_freeeda>\" to it.\n  3) source ~/.bashrc")
        exit(0)

    HOME=self.FreeEDA_HOME="/modelEditor/"
  # Open the circuit file 
    self.fileName=filename
  # Open parameter file
    if os.path.exists(self.fileName):
      try:
        f = open(self.fileName)
      except :
        tkMessageBox.showwarning("Bad input","Circuit netlist does not exit, please try again")
        return
    else:
        tkMessageBox.showwarning("Bad input","Circuit netlist does not exit, please try again")
        return

  # Read the data from file
    data=f.read()
  
  # Close the file
    f.close()
    netlist=data.splitlines()
  # Find the various model library required
    self.modelInfo={}
    
    for eachline in netlist:
      eachline=eachline.strip()
      if len(eachline)>1:
        eachline=eachline.lower()
        words=eachline.split()
        if eachline[0]=='d':
          modelName=words[3]
	  modelType=words[3]
          self.modelList.append(words[0]+":"+modelName)
	  self.modelInfo[modelName]=modelType
        elif eachline[0]=='q':
          modelName=words[4]
	  if words[4]=='npn':
          	modelType="NPN"
	  elif words[4]=='pnp':
	        modelType="PNP"
	  else:
	       modelType=words[4]	
	       				
          self.modelList.append(words[0]+":"+modelName)
	  self.modelInfo[modelName]=modelType
          
        elif eachline[0]=='m':
            modelName=words[4]
	    if words[4]=='nmos':
		modelType="NMOS"
	    elif words[4]=='pmos':
		modelType="PMOS"
	    else:
		modelType=words[4]
	    self.modelList.append(words[0]+":"+modelName)
	    self.modelInfo[modelName]=modelType
	
        elif eachline[0]=='j':
	    modelName=words[4]
	    if words[4]=='pjf':
		modelType='PJF'
	    elif words[4]=='njf':
		modelType='NJF'
	    else:
		modelType=words[4]	    
            self.modelList.append(words[0]+":"+modelName)
	    self.modelInfo[modelName]=modelType
        else:
	  continue
	  
  # Create the dialog.
      	
    self.dialog = Pmw.SelectionDialog(parent,
          	title = 'Model Selector',
          	buttons = ('OK', 'Cancel'),
          	defaultbutton = 'OK',
          	scrolledlist_labelpos = 'n',
          	label_text = 'Please select the model',
          	scrolledlist_items=self.modelList,
          	command = self.apply,
          	)
    self.dialog.pack(fill = 'both', expand=1, padx=5, pady=5)
    self.dialog.activate()

  # Protocol when window is deleted.
    self.dialog.protocol("WM_DELETE_WINDOW",self.cancel)
Example #58
0
    def dessineBT(self):

        # variables locales
        vLigne = 1  # N° de ligne pour le positionnement des composants
        vNomBouton = ""
        vIndice = 0
        vFen = self.fenetre

        # Composants de la fenêtre
        Label(vFen, text="Informations transmission", fg="blue",
              bg="orange").grid(row=vLigne,
                                column=0,
                                columnspan=8,
                                sticky=W + E)
        vLigne += 1

        Label(vFen, text="Groupe Date/Heure : ").grid(row=vLigne,
                                                      column=0,
                                                      sticky=W)
        self.efGdh = Commun.gdhWidget(vFen, vFen)
        self.efGdh.grid(row=vLigne, column=1, sticky=W)
        self.iGdh = IntVar()
        self.ckGdh = Checkbutton(
            vFen,
            text="Recalculer le GDH lors de la validation",
            variable=self.iGdh)
        self.ckGdh.grid(row=vLigne, column=3, columnspan=2, sticky=W)
        self.ckGdh.select()
        vLigne += 1
        Label(vFen, text="Emis par : ").grid(row=vLigne, column=0, sticky=W)
        self.cbEmetteur = Commun.indicatifWidget(vFen, vFen, self.root)
        self.cbEmetteur.grid(row=vLigne, column=1, sticky=W)
        Label(vFen, text="Reçu par : ").grid(row=vLigne, column=3, sticky=W)
        self.cbDestinataire = Commun.indicatifWidget(vFen, vFen, self.root)
        self.cbDestinataire.grid(row=vLigne, column=4, columnspan=4, sticky=W)
        vLigne += 1
        Label(vFen, text="Instructions particulières : ").grid(row=vLigne,
                                                                column=0,
                                                                sticky=W)
        self.eInstruc = Entry(vFen)
        self.eInstruc.grid(row=vLigne, column=1, columnspan=4, sticky=W + E)
        vLigne += 1

        Label(vFen, text="Message Bilan Temporaire", fg="blue",
              bg="orange").grid(row=vLigne,
                                column=0,
                                columnspan=8,
                                sticky=W + E)
        vLigne += 1

        Label(vFen, text="Entête du Message", fg="blue",
              bg="cyan").grid(row=vLigne, column=0, columnspan=8, sticky=W + E)
        vLigne += 1

        Label(vFen, text="Origine : ").grid(row=vLigne, column=0, sticky=W)
        self.efOrigine = Pmw.EntryField(vFen, validate=Commun.nonVideValidator)
        self.efOrigine.grid(row=vLigne, column=1, sticky=W)
        vLigne += 1
        Label(vFen, text="Destinataires Action: ").grid(row=vLigne,
                                                        column=0,
                                                        sticky=W)
        self.efDestAction = Pmw.EntryField(vFen,
                                           validate=Commun.nonVideValidator)
        self.efDestAction.grid(row=vLigne,
                               column=1,
                               columnspan=4,
                               sticky=W + E)
        Label(vFen,
              text="(utilisez le / comme séparateur)").grid(row=vLigne,
                                                             rowspan=2,
                                                             column=5,
                                                             columnspan=3,
                                                             sticky=W)
        vLigne += 1
        Label(vFen, text="Destinataires Info: ").grid(row=vLigne,
                                                      column=0,
                                                      sticky=W)
        self.eDestInfo = Entry(vFen)
        self.eDestInfo.grid(row=vLigne, column=1, columnspan=4, sticky=W + E)
        vLigne += 1
        Label(vFen, text="Degré d'Urgence : ").grid(row=vLigne,
                                                     column=0,
                                                     sticky=W)
        self.cbDegUrg = Commun.comboWidget(self.root, vFen,
                                           self.root.cfgListe['DegUrgOBNT'])
        self.cbDegUrg.grid(row=vLigne, column=1, columnspan=2, sticky=W)
        vLigne += 1

        Label(vFen, text="Corps du message ", fg="blue",
              bg="cyan").grid(row=vLigne, column=0, columnspan=8, sticky=W + E)
        vLigne += 1

        Label(vFen, text="Objet : ").grid(row=vLigne, column=0, sticky=W)
        self.efObjet = Pmw.EntryField(vFen, validate=Commun.nonVideValidator)
        self.efObjet.grid(row=vLigne, column=1, columnspan=6, sticky=W + E)
        vLigne += 1
        Label(vFen, text="Dépt. Alerté et Touché : ").grid(row=vLigne,
                                                              column=0,
                                                              sticky=W)
        self.eDptAET = Entry(vFen)
        self.eDptAET.grid(row=vLigne, column=1, sticky=W)
        Label(vFen, text="Dépt. Touché et Non Alerté : ").grid(row=vLigne,
                                                                  column=3,
                                                                  sticky=W)
        self.eDptTNA = Entry(vFen)
        self.eDptTNA.grid(row=vLigne, column=4, sticky=W)
        Label(vFen, text="Dept. Alerté et Non Touché : ").grid(row=vLigne,
                                                                 column=6,
                                                                 sticky=W)
        self.eDptANT = Entry(vFen)
        self.eDptANT.grid(row=vLigne, column=7, sticky=W)
        vLigne += 1

        Label(vFen, text="Plan ORSEC : ").grid(row=vLigne, column=0, sticky=W)
        self.cbORSEC = Pmw.ComboBox(
            vFen,
            scrolledlist_items=self.root.cfgListe['Orsec'],
            listheight=80)
        self.cbORSEC.grid(row=vLigne, column=1, columnspan=2, sticky=W)
        self.cbORSEC.selectitem(0)

        Label(vFen, text="Portée ORSEC : ").grid(row=vLigne,
                                                  column=3,
                                                  sticky=W)
        self.cbPortee = Pmw.ComboBox(
            vFen,
            scrolledlist_items=self.root.cfgListe['Portee'],
            listheight=80)
        self.cbPortee.grid(row=vLigne, column=4, columnspan=2, sticky=W)
        self.cbPortee.selectitem(0)
        self.rbCrise = Pmw.RadioSelect(
            vFen,
            buttontype="radiobutton",
            labelpos=W,
            label_text="Cellule de Crise activée : ")
        self.rbCrise.grid(row=vLigne, column=6, columnspan=2, sticky=W)
        self.rbCrise.add("Oui")
        self.rbCrise.add("Non")
        self.rbCrise.invoke("Non")
        vLigne += 1

        self.notebook = Pmw.NoteBook(vFen)
        self.notebook.grid(row=vLigne, column=0, columnspan=8, sticky=W + E)
        self.nbTab1 = self.notebook.add('Bilan')
        self.nbTab1.grid_columnconfigure(1, weight=2)
        self.nbTab1.grid_columnconfigure(4, weight=2)
        self.nbTab1.grid_columnconfigure(7, weight=2)
        self.nbTab1.grid_columnconfigure(8, weight=2)
        vLig = 0
        Label(self.nbTab1,
              text="Bilans Humain et Matériel",
              fg="blue",
              bg="darkgray").grid(row=vLig,
                                  column=0,
                                  columnspan=9,
                                  sticky=W + E)
        vLig += 1

        Label(self.nbTab1, text="Nb Décédés : ").grid(row=vLig,
                                                         column=0,
                                                         sticky=W)
        self.eDecedes = Entry(self.nbTab1)
        self.eDecedes.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab1, text="Nb Blessés : ").grid(row=vLig,
                                                       column=3,
                                                       sticky=W)
        self.eBlesses = Entry(self.nbTab1)
        self.eBlesses.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab1, text="Nb Déplacés ou Relogés : ").grid(row=vLig,
                                                                     column=6,
                                                                     sticky=W)
        self.eDeplaces = Entry(self.nbTab1)
        self.eDeplaces.grid(row=vLig, column=7, sticky=W)
        vLig += 1

        Label(self.nbTab1, text="Nb d'interventions : ").grid(row=vLig,
                                                              column=0,
                                                              sticky=W)
        self.eInterv = Entry(self.nbTab1)
        self.eInterv.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab1, text="Hélitreuillés : ").grid(row=vLig,
                                                           column=3,
                                                           sticky=W)
        self.eHeli = Entry(self.nbTab1)
        self.eHeli.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab1, text="Axe coupés : ").grid(row=vLig,
                                                       column=6,
                                                       sticky=W)
        self.eAxes = Entry(self.nbTab1)
        self.eAxes.grid(row=vLig, column=7, sticky=W)
        vLig += 1

        Label(self.nbTab1, text="Foyers Privés d'Eau : ").grid(row=vLig,
                                                                column=0,
                                                                sticky=W)
        self.eSansEau = Entry(self.nbTab1)
        self.eSansEau.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab1,
              text="Foyers Privés Electricité : ").grid(row=vLig,
                                                          column=3,
                                                          sticky=W)
        self.eSansElec = Entry(self.nbTab1)
        self.eSansElec.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab1, text="Foyers Privés Telephone : ").grid(row=vLig,
                                                                    column=6,
                                                                    sticky=W)
        self.eSansTel = Entry(self.nbTab1)
        self.eSansTel.grid(row=vLig, column=7, sticky=W)
        vLig += 1

        self.nbTab2 = self.notebook.add('Effectifs')
        self.nbTab2.grid_columnconfigure(1, weight=2)
        self.nbTab2.grid_columnconfigure(4, weight=2)
        self.nbTab2.grid_columnconfigure(7, weight=2)
        self.nbTab2.grid_columnconfigure(8, weight=2)
        vLig = 0
        Label(self.nbTab2, text="Effectifs Engagés", fg="blue",
              bg="darkgray").grid(row=vLig,
                                  column=0,
                                  columnspan=9,
                                  sticky=W + E)
        vLig += 1

        Label(self.nbTab2, text="SP Locaux : ").grid(row=vLig,
                                                     column=0,
                                                     sticky=W)
        self.eSPLoc = Entry(self.nbTab2)
        self.eSPLoc.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab2, text="SP Extra zonaux : ").grid(row=vLig,
                                                           column=3,
                                                           sticky=W)
        self.eSPExt = Entry(self.nbTab2)
        self.eSPExt.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab2,
              text="Militaires Sécurité Civile : ").grid(row=vLig,
                                                           column=6,
                                                           sticky=W)
        self.eMilSC = Entry(self.nbTab2)
        self.eMilSC.grid(row=vLig, column=7, sticky=W)
        vLig += 1

        Label(self.nbTab2, text="Police/Gendarmerie : ").grid(row=vLig,
                                                              column=0,
                                                              sticky=W)
        self.ePolice = Entry(self.nbTab2)
        self.ePolice.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab2, text="Militaires : ").grid(row=vLig,
                                                      column=3,
                                                      sticky=W)
        self.eArmee = Entry(self.nbTab2)
        self.eArmee.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab2, text="Asso. Sécurité Civile: ").grid(row=vLig,
                                                                  column=6,
                                                                  sticky=W)
        self.eAssoSC = Entry(self.nbTab2)
        self.eAssoSC.grid(row=vLig, column=7, sticky=W)
        vLig += 1

        Label(self.nbTab2, text="EDF / GDF : ").grid(row=vLig,
                                                     column=0,
                                                     sticky=W)
        self.eElec = Entry(self.nbTab2)
        self.eElec.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab2, text="France Télecom : ").grid(row=vLig,
                                                           column=3,
                                                           sticky=W)
        self.eTelecom = Entry(self.nbTab2)
        self.eTelecom.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab2, text="DDE/DIR/CG : ").grid(row=vLig,
                                                      column=6,
                                                      sticky=W)
        self.eEquip = Entry(self.nbTab2)
        self.eEquip.grid(row=vLig, column=7, sticky=W)
        vLig += 1

        self.nbTab3 = self.notebook.add('Moyens')
        self.nbTab3.grid_columnconfigure(1, weight=2)
        self.nbTab3.grid_columnconfigure(4, weight=2)
        self.nbTab3.grid_columnconfigure(7, weight=2)
        self.nbTab3.grid_columnconfigure(8, weight=2)
        vLig = 0
        Label(self.nbTab3,
              text="Moyens Matériels Engagés",
              fg="blue",
              bg="darkgray").grid(row=vLig,
                                  column=0,
                                  columnspan=9,
                                  sticky=W + E)
        vLig += 1

        Label(self.nbTab3,
              text="Hélicoptères Sécurité Civile : ").grid(row=vLig,
                                                               column=0,
                                                               sticky=W)
        self.eHeliSC = Entry(self.nbTab3)
        self.eHeliSC.grid(row=vLig, column=1, sticky=W)
        Label(self.nbTab3, text="Hélicoptères Militaires : ").grid(row=vLig,
                                                                     column=3,
                                                                     sticky=W)
        self.eHeliMil = Entry(self.nbTab3)
        self.eHeliMil.grid(row=vLig, column=4, sticky=W)
        Label(self.nbTab3, text="Groupes électrogènes : ").grid(row=vLig,
                                                                  column=6,
                                                                  sticky=W)
        self.eGrpElec = Entry(self.nbTab3)
        self.eGrpElec.grid(row=vLig, column=7, sticky=W + E)
        vLig += 1

        Label(self.nbTab3, text="Autres : ").grid(row=vLig, column=0, sticky=W)
        self.eAutres = Entry(self.nbTab3)
        self.eAutres.grid(row=vLig, column=1, columnspan=3, sticky=W + E)
        vLig += 1

        self.notebook.setnaturalsize()
        vLigne += 4
        Label(vFen, text="Final du message ", fg="blue",
              bg="cyan").grid(row=vLigne, column=0, columnspan=8, sticky=W + E)
        vLigne += 1
        Label(vFen, text="GDH Dépôt/Rédaction : ").grid(row=vLigne,
                                                           column=0,
                                                           sticky=W)
        self.efGdhDep = Commun.gdhWidget(vFen, vFen)
        self.efGdhDep.grid(row=vLigne, column=1, sticky=W)
        self.rbACK = Pmw.RadioSelect(
            vFen,
            buttontype="radiobutton",
            labelpos=W,
            label_text="Demande Accusé de Réception : ")
        self.rbACK.grid(row=vLigne, column=4, columnspan=3, sticky=W)
        self.rbACK.add("Oui")
        self.rbACK.add("Non")
        vLigne += 1

        Label(vFen, text="Fin de Message ", fg="blue",
              bg="orange").grid(row=vLigne,
                                column=0,
                                columnspan=8,
                                sticky=W + E)
        vLigne += 1

        Button(vFen,
               text="Valider",
               command=self.validerBT,
               fg="red",
               underline=0).grid(row=vLigne,
                                 column=1,
                                 padx=5,
                                 pady=5,
                                 sticky=W + E)
        Button(vFen,
               text="Annuler",
               command=self.annulerBT,
               fg="red",
               underline=1).grid(row=vLigne,
                                 column=4,
                                 padx=5,
                                 pady=5,
                                 sticky=W + E)
        Button(vFen,
               text="Quitter",
               command=self.quitterBT,
               fg="red",
               underline=0).grid(row=vLigne,
                                 column=7,
                                 padx=5,
                                 pady=5,
                                 sticky=W + E)
    def __init__(self, parent):
        self.parent = parent

        #----------------------------------------------------------------------------------------
        # Begin the creation of the file type selection
        #----------------------------------------------------------------------------------------
        self.group_file_filter = Pmw.Group(self.parent.control_frame1,
                                           tag_text='Filter File Search',
                                           tag_font=('Times', 18, 'bold'),
                                           tagindent=25)

        self.data_filter = Pmw.ComboBox(
            self.group_file_filter.interior(),
            scrolledlist_items=pub_controls.datatypes,
            entryfield_value=pub_controls.datatypes[0],
            #    label_text = 'Filter File Search:',
            #    labelpos = 'w',
            entry_state='readonly',
            entry_font=('Times', 16, 'bold'),
            entry_background='white',
            entry_foreground='black',
            #selectioncommand=pub_controls.Command(self.evt_data_filter)
        )
        #self.parent.balloon.bind(self.data_filter, "Return specific files.")
        #self.parent.balloon.bind( self.data_filter._arrowBtn, 'Files types.' )

        self.data_filter.pack(side='top', fill='x', pady=5)
        self.group_file_filter.pack(side='top', fill='x', pady=3)
        #----------------------------------------------------------------------------------------
        # End the creation of the file type selection
        #----------------------------------------------------------------------------------------

        #----------------------------------------------------------------------------------------
        # Begin the creation of the directory, file, and combo directoy box
        #----------------------------------------------------------------------------------------
        #self.parent.control_frame2 = Tkinter.Frame(self.parent.control_frame1, width=5,height=5, background='aliceblue')
        self.group_list_generation = Pmw.Group(self.parent.control_frame1,
                                               tag_text='Generate List',
                                               tag_font=('Times', 18, 'bold'),
                                               tagindent=25)
        self.parent.control_frame2 = self.group_list_generation.interior()

        self.directory_icon = Tkinter.PhotoImage(file=file2_gif)
        self.file_icon = Tkinter.PhotoImage(file=folder2_gif)
        self.stop_icon = Tkinter.PhotoImage(file=stop_gif)

        # Create the directory button icon
        lw = Pmw.LabeledWidget(
            self.parent.control_frame2,
            labelpos='w',
            label_text="Generate list from directory: ",
            label_font=('Times', 16, 'bold'),
            hull_relief='raised',
            hull_borderwidth=2,
        )
        lw.pack(fill='x', padx=1, pady=3)

        self.generating_file_list_flg = 0
        self.directory_button = Tkinter.Button(
            lw.interior(),
            image=self.directory_icon,
            bg='lightblue',
            command=pub_controls.Command(self.evt_popup_directory_window))
        self.directory_button.image = self.directory_icon  # save the image from garbage collection
        #self.parent.balloon.bind(self.directory_button, "Popup directory selection window.")
        self.directory_button.pack(side='left', fill='x')

        # Create the file button icon
        lw = Pmw.LabeledWidget(
            self.parent.control_frame2,
            labelpos='w',
            label_text="Generate list from file:         ",
            label_font=('Times', 16, 'bold'),
            hull_relief='raised',
            hull_borderwidth=2,
        )
        lw.pack(fill='x', padx=1, pady=3)
        self.file_button = Tkinter.Button(lw.interior(),
                                          image=self.file_icon,
                                          bg='lightblue',
                                          command=pub_controls.Command(
                                              self.evt_popup_file_window))
        self.file_button.image = self.file_icon  # save the image from garbage collection
        #self.parent.balloon.bind(self.file_button, "Popup text file selection window.")
        self.file_button.pack(side='left', fill='x')

        # Set up directory combo box
        d, f = _scn_a_dir(self.parent)
        self.directory_combo = Pmw.ComboBox(
            self.parent.control_frame2,
            scrolledlist_items=d,
            entryfield_value=os.getcwd(),
            entry_font=('Times', 16, 'bold'),
            entry_background='white',
            entry_foreground='black',
            selectioncommand=pub_controls.Command(self.evt_enter_directory))
        #self.directory_combo.configure( menubutton_text=gui_control.dbdchlst[0] )
        #self.parent.balloon.bind(self.directory_combo, "Enter directory and/or text file.")
        #self.parent.balloon.bind( self.directory_combo._arrowBtn, 'View and select directories to generate dataset list.' )

        self.directory_combo.component('entry').bind(
            "<Key>", pub_controls.Command(self.evt_change_color))
        self.directory_combo.component('entry').bind(
            "<Return>", pub_controls.Command(self.evt_enter_directory))
        self.directory_combo.component('entry').bind(
            '<Tab>', pub_controls.Command(self.evt_tab))
        self.directory_combo.component('entry').bind(
            "<BackSpace>", pub_controls.Command(self.evt_backspace))

        #self.directory_combo.pack(side = 'left', expand = 1, fill='x')

        # Create the stop button icon
        lw = Pmw.LabeledWidget(
            self.parent.control_frame2,
            labelpos='w',
            label_text="Stop list generation:             ",
            label_font=('Times', 16, 'bold'),
            hull_relief='raised',
            hull_borderwidth=2,
        )
        lw.pack(fill='x', padx=1, pady=3)
        self.stop_listing_flg = 0
        self.stop_button = Tkinter.Button(lw.interior(),
                                          image=self.stop_icon,
                                          bg='lightblue',
                                          command=pub_controls.Command(
                                              self.stop_listing))
        self.stop_button.image = self.stop_icon  # save the image from garbage collection
        #self.parent.balloon.bind( self.stop_button, "Stop the generation of the dataset list.")
        self.stop_button.pack(side='left', fill='x')

        self.parent.control_frame2.pack(side="top", fill='x', pady=5)
        self.group_list_generation.pack(side='top', fill='x', pady=3)
        #----------------------------------------------------------------------------------------
        # End the creation of the directory, file, and combo directoy box
        #----------------------------------------------------------------------------------------

        #----------------------------------------------------------------------------------------
        # Begin the regular expression widget
        #----------------------------------------------------------------------------------------
        self.group_list = Pmw.Group(self.parent.control_frame1,
                                    tag_text='Regular Expressions',
                                    tag_font=('Times', 18, 'bold'),
                                    tagindent=25)
        self.group_list.pack(side='top', fill='x')

        self.scl1 = Pmw.ScrolledText(self.group_list.interior(),
                                     text_background='aliceblue',
                                     text_foreground='black',
                                     text_wrap='none',
                                     usehullsize=1,
                                     hull_width=100,
                                     hull_height=100)
        #horizscrollbar_width=50,
        #vertscrollbar_width=50 )
        #self.scl1.grid(row=0, column=0 )
        self.scl1.pack(side='top', expand=1, fill='both')

        # Create and pack a vertical RadioSelect widget, with checkbuttons.
        self.checkbuttons = Pmw.RadioSelect(
            self.group_list.interior(),
            buttontype='checkbutton',
            orient='horizontal',
            labelpos='w',
            #       command = self.checkbuttoncallback,
            hull_borderwidth=2,
            hull_relief='ridge',
        )
        self.checkbuttons.pack(side='top', expand=1, padx=10, pady=10)

        # Add some buttons to the checkbutton RadioSelect.
        for text in ('Ignore Case', 'Multi-Line', 'Verbose'):
            self.checkbuttons.add(text)
Example #60
0
from tkinter import *
import Pmw

root = Tk()

balloon = Pmw.Balloon(root)
frame = Frame(root)
frame.pack(padx=10, pady=5)
field = Pmw.EntryField(frame, labelpos=W, label_text='Name:')
field.setentry('A.N. Other')
field.pack(side=LEFT, padx=10)

balloon.bind(field, 'Your name', 'Enter your name')
check = Button(frame, text='Check')
balloon.bind(check, 'Look up', 'Check if name is in the database')
frame.pack()

messageBar = Pmw.MessageBar(root,
                            entry_width=40,
                            entry_relief=GROOVE,
                            labelpos=W,
                            label_text='Status: ')
messageBar.pack(fill=X, expand=1, padx=10, pady=5)
balloon.configure(statuscommand=messageBar.helpmessage)

root.mainloop()