Esempio n. 1
0
    def _add_filename(self, frame, index, name, mode, option):
        if option:
            self.function[-1] = lambda v: [option, v]
        else:
            self.function[-1] = lambda v: [v]

        self.variables[-1] = StringVar()
        var = self.variables[-1]

        def set_name():
            if mode == "r":
                fn = tkFileDialog.askopenfilename(initialdir=".")
            else:
                fn = tkFileDialog.asksaveasfilename(initialdir=".")
            var.set(fn)

        label = Label(frame, text=name)
        label.grid(row=index, column=0, sticky="W", padx=10)

        field_button = Frame(frame)
        Grid.columnconfigure(field_button, 0, weight=1)

        field = Entry(field_button, textvariable=var)
        field.grid(row=0, column=0, sticky="WE")
        button = Button(field_button,
                        text="...",
                        command=set_name,
                        width=1,
                        padding=0)
        button.grid(row=0, column=1)

        field_button.grid(row=index, column=1, sticky="WE")
Esempio n. 2
0
 def __init__(self, parent, consoleWidth = DEFAULT_CONSOLE_WIDTH, consoleHeight = DEFAULT_CONSOLE_HEIGHT):
     '''
     Creates and returns a new console object.
     
     _Parameters_
     parent (required) - The parent widget object under which this console is to be created.
     consoleWidth (optional) - The width in characters to display the console (default = 100).
     consoleHeight (optional) - The height in lines to display the console (default = 20).
     
     _Return_
     ConsoleFrame Object
     '''
     Frame.__init__(self, parent)
     
     self.parent = parent
     
     #Member widget creation
     self.Console = Text(self.parent)
     self._XScroll = Scrollbar(self.parent)
     self._YScroll = Scrollbar(self.parent)
     
     #Widget configuration
     self.Console.config(xscrollcommand = self._XScroll.set,
                         yscrollcommand = self._YScroll.set,
                         width = consoleWidth,
                         height = consoleHeight,
                         bg = "black",
                         fg = "green",
                         selectbackground = "green",
                         selectforeground = "black",
                         wrap = "none",
                         state = "disabled")
     self._XScroll.config(command = self.Console.xview,
                         orient = "horizontal")
     self._YScroll.config(command = self.Console.yview,
                         orient = "vertical")
     
     #Geometry control
     Grid.rowconfigure(self.parent, 0, weight=1)
     Grid.columnconfigure(self.parent, 0, weight=1)
     
     self.Console.grid(row = 0, column = 0,
                       sticky = "n"+"s"+"e"+"w")
     self._YScroll.grid(row = 0, column = 1,
                       sticky = "n"+"s"+"e"+"w")
     self._XScroll.grid(row = 1, column = 0,
                       sticky = "n"+"s"+"e"+"w")
     
     return
Esempio n. 3
0
        def initUI(self):
            self.parent.title("Biicode serial monitor %s" % self.port)
            self.style = Style()  # We need to define a style, otherwhise seems flat whit in macos
            self.style.theme_use(get_style())
            for x in range(1):
                Grid.columnconfigure(self, x, weight=1)
            for y in [1, 2]:
                Grid.rowconfigure(self, y, weight=1)

            self._make_top_bar()
            self._make_user_input()
            self._make_rcv_log()
            self._make_button_bar()

            self.pack(fill=BOTH, expand=1)

            self.serial_buffer = ""
            self.count = 0
            self.running = True
            self.after(50, self.read_serial)  # check serial again soon
Esempio n. 4
0
        def initUI(self):
            self.parent.title("Biicode serial monitor %s" % self.port)
            self.style = Style(
            )  # We need to define a style, otherwhise seems flat whit in macos
            self.style.theme_use(get_style())
            for x in range(1):
                Grid.columnconfigure(self, x, weight=1)
            for y in [1, 2]:
                Grid.rowconfigure(self, y, weight=1)

            self._make_top_bar()
            self._make_user_input()
            self._make_rcv_log()
            self._make_button_bar()

            self.pack(fill=BOTH, expand=1)

            self.serial_buffer = ""
            self.count = 0
            self.running = True
            self.after(50, self.read_serial)  # check serial again soon
Esempio n. 5
0
File: board.py Progetto: Avox3/Chess
    def starting(self):
        """ Creates the board's rows and columns. """

        # create pieces
        self.set_starting_pieces()
        square_style = {'borderwidth': 0, 'width': 5, 'height': 2}

        # create responsive board as 8x8 grid
        for row in xrange(8):
            row_squares = []

            Grid.rowconfigure(self.root, row, weight=1)

            for col in xrange(8):
                Grid.columnconfigure(self.root, col, weight=1)

                if (row + col) % 2 == 0:
                    square_color = 'white'
                else:
                    square_color = 'grey'

                square_btn = SquareBtn(parent=self.root,
                                       row=row,
                                       col=col,
                                       bg=square_color,
                                       **square_style)
                square_btn.grid(row=row, column=col, sticky='nsew')

                square_piece = self.get_piece(row, col)
                if square_piece:
                    square_btn.config(image=square_piece.icon)
                    square_btn.image = square_piece.icon

                square_btn.config(
                    command=lambda x=(row, col): self.button_command(x))

                row_squares.append(square_btn)
            self.squares.append(row_squares)
Esempio n. 6
0
    def initUI(self, parser) :
        # TODO required arguments
        # TODO repeated arguments (e.g. filenames)

        self.parent.title(self.progname)
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()

        Grid.rowconfigure(self,1,weight=1)
        Grid.columnconfigure(self,0,weight=1)

        inputFrame = Frame(self)
        inputFrame.grid(row=0, column=0, sticky='WE')

        outputFrame = Frame(self)
        outputFrame.grid(row=1, column=0, sticky='WENS')

        self.outputText = ReadOnlyText(outputFrame)
        self.outputText.pack(fill=BOTH, expand=1)

        # Main controls frame
        mainFrame = Frame(inputFrame)
        mainFrame.pack(fill=BOTH, expand=1)

        # Auto-resize column
        Grid.columnconfigure(mainFrame,1,weight=1)

        # Ok button
        okButton = Button(inputFrame, text='Run', command=self.run, default='active')
        okButton.pack(side=RIGHT, padx=5, pady=5)

        # Cancel button
        cancelButton = Button(inputFrame, text='Exit', command=self.quit)
        cancelButton.pack(side=RIGHT)

        # Add controls to mainframe for all options
        for index, action in enumerate(parser._actions) :
            action_type = type(action).__name__
            if action_type == '_HelpAction' :
                pass
            else :
                self.function.append(lambda v : [v])
                self.variables.append(None)
                if action.choices :
                    self._add_choice( mainFrame, index, action.dest, action.choices, action.default, action.option_strings[0] )
                elif action_type == '_StoreTrueAction' :
                    self._add_check( mainFrame, index, action.dest, False, action.option_strings[0] )
                elif action_type == '_CountAction' :
                    self._add_count( mainFrame, index, action.dest, 0, action.option_strings[0] )
                elif action.type and action.type.__name__ == 'inputfile' :
                    self._add_filename( mainFrame, index, action.dest, 'r', action.option_strings )
                elif action.type and action.type.__name__ == 'outputfile' :
                    self._add_filename( mainFrame, index, action.dest, 'w', action.option_strings )
                else :
                    self._add_field( mainFrame, index, action.dest )
Esempio n. 7
0
        comPortEntry.insert(0, port_no)
if not comPortEntry.get():
    comPortEntry.configure(fg='red')
    comPortEntry.insert(0, 'NONE')
goButton = Button(root,
                  bd=4,
                  font=('times', 12, 'bold'),
                  text="CONNECT",
                  bg='greenyellow',
                  command=ConnectIoTAdapter)
goButton.grid(row=12, column=17, rowspan=2, columnspan=1, sticky=W + E + N + S)

Button(root, state=DISABLED, text=COPYRIGHT_STR).grid(row=14,
                                                      column=0,
                                                      rowspan=1,
                                                      columnspan=18,
                                                      sticky=W + E + N + S)

# Fill elements in the whole frame
for x in range(18):
    Grid.columnconfigure(root, x, weight=1)
for y in range(16):
    Grid.rowconfigure(root, y, weight=1)

# Update Title, install Close event handlers and Launch the GUI.
root.title(WINDOW_TITLE)
root.protocol('WM_DELETE_WINDOW', ExitDashboard)
root.mainloop()

sys.exit(0)
Esempio n. 8
0
from Tkinter import Tk, Listbox, Entry, END, mainloop, Grid, N, S, E, W, StringVar

LEAVE_ITEM = '..'
BOOKMARK_URL = 'bookmarks://'
BOOKMARK_FILE = expanduser('~/.benthos_bookmarks')
REVEAL_IN_FINDER = """
    tell application "Finder"
        reveal POSIX file "%s"
        activate
    end tell
"""

root = Tk()
root.geometry("800x500")

Grid.columnconfigure(root, 0, weight=1)
Grid.columnconfigure(root, 1, weight=1)
Grid.rowconfigure(root, 0, weight=1)

left_panel = Listbox(root, exportselection=0)
right_panel = Listbox(root, exportselection=0)
command_string = StringVar(root)
command_line = Entry(root, textvariable=command_string)

left_panel.grid(row=0, column=0, sticky=N+S+E+W)
right_panel.grid(row=0, column=1, sticky=N+S+E+W)
command_line.grid(row=1, column=0, columnspan=2, sticky=N+S+E+W)


def path_components(path):
    components = []
Esempio n. 9
0
def consensusHarness(cSize,depth):
	print("^"*100)
	a = ArtificialPhylogeny(size=cSize,numChromosomes=5)
	evRates = []
	while len( a.tree.getTips() ) < depth:
		# evRate = rn.uniform(0.2,0.75)
		evRate = 0.3
		evRates.append(evRate)
		a.evolve(evolutionRate=evRate)


	print("Finished generating phylogeny. Score is {}. Rates were {}".format( a.tree.getScore(), evRates ))

	u = UPGMA( [t.genome for t in a.tree.getTips()])
	u.calculate()

	root = Tk()
	d1 = TreeDrawer(root)
	d1.draw(a.tree,row=0,col=0)
	d2 = TreeDrawer(root, leafs=d1.leafs)
	d2.draw(u.tree,row=0,col=1)


	tree = u.tree 
	uRF = fastRFDist(tree.toTuple(), a.tree.toTuple())

	print("Finished upgma. Score is {}. RF distance is {}".format( tree.getScore(), uRF))

	uRF = fastRFDist(a.tree.toTuple(), tree.toTuple())
	uScore = tree.getScore()

	oldScore = tree.getScore()
	newScore = 0
	counter = 0

	n = NNI( tree )
	nniTreeDrawers = []
	while abs(newScore - oldScore) >= 1 and counter < 5:
		counter += 1
		n.calculate(deepScoring=True)
		oldScore = newScore
		newScore = sum([t.getScore() for t in n.trees])
		nRFs = [fastRFDist(t.toTuple(), a.tree.toTuple()) for t in n.trees]
		print("Running NNI. Current scores are {}. Current RF distances are {}".format([t.getScore() for t in n.trees], nRFs))

	nniTreeDrawers = []
	for i,tr in enumerate(n.trees):
		t= TreeDrawer(root,leafs=d1.leafs)
		t.draw(tr,row=1,col=i)


	nRFs = [fastRFDist(t.toTuple(), a.tree.toTuple()) for t in n.trees]

	print("Finished NNI. Scores are {}. RF distances are {}".format([t.getScore() for t in n.trees], nRFs))

	c = ConsensusTree(n.trees)
	c.calculate()

	cRF = fastRFDist(tree.toTuple(), a.tree.toTuple())

	print("Finished consensus. Score is {}. RF distance is {}".format( tree.getScore(), cRF))

	tree = Tree( c.conTree )
	t1= TreeDrawer(root,leafs=d1.leafs)
	t1.draw(tree,row=2,col=0)
	

	c.calculateNewGenomes()

	cRF = fastRFDist(c.conTree.toTuple(), a.tree.toTuple())

	print("Recalculated Genomes in consensusTree. Score is {}. RF distance is {}".format( tree.getScore(), cRF))
	
	t2= TreeDrawer(root,leafs=d1.leafs)
	t2.draw(c.conTree,row=2,col=1)

	for x in (0,1,2):
		Grid.columnconfigure(root,x,weight=1)
	for y in (0,1,2):
		Grid.rowconfigure(root,y,weight=1)
	root.mainloop()

	nScore = tree.getScore()