예제 #1
0
    def __init__(self, converter, master=None):
        Frame.__init__(self, master)

        master.title("Ai Variable tool")

        self.converter = converter

        self.grid(row=0, sticky=(tk.N + tk.E + tk.W + tk.S))
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.tabbedPane = Notebook(self, name="tabbed-pane")
        self.tabbedPane.grid(row=0,
                             column=0,
                             sticky=(tk.N + tk.E + tk.W + tk.S))

        self.btnSave = tk.Button(self,
                                 text="Guardar",
                                 command=self.btnSaveCallback)
        self.btnSave.grid(row=1, column=0, sticky=(tk.N + tk.E + tk.W + tk.S))

        self.rawTextPanel = RawTextPane(self.tabbedPane)
        self.rawTextPanel.grid(row=0,
                               column=0,
                               sticky=(tk.N + tk.E + tk.W + tk.S))

        self.numbersPanel = NumbersPane(self.tabbedPane)
        self.numbersPanel.grid(row=0,
                               column=0,
                               sticky=(tk.N + tk.E + tk.W + tk.S))

        self.tabbedPane.add(self.numbersPanel, text="Series de numeros")
        self.tabbedPane.add(self.rawTextPanel, text="Texto en crudo")

        self.panels = [self.numbersPanel, self.rawTextPanel]
예제 #2
0
파일: view.py 프로젝트: oguntli/bugjar
    def _setup_file_lists(self):

        self.file_notebook = Notebook(self.content, padding=(0, 5, 0, 5))
        self.content.add(self.file_notebook)

        self._setup_stack_frame_list()
        self._setup_breakpoint_list()
예제 #3
0
    def __init__(self, parent, user):
        Notebook.__init__(self, parent)

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

        for wid, workspace in user.workspaces.iteritems():
            widget = WorkspaceWidget(self, workspace)
            self.add(widget, text=workspace.name)

        checkIdleThread = IdleChecker(user)
        checkIdleThread.start()
예제 #4
0
파일: main.py 프로젝트: tdengg/pylastic
 def _create_panel(self):
     
     panel = Frame(self, name='elastic')
     #panel.pack(side=TOP, fill=BOTH, expand=Y)
     panel.grid(row=0, column=0, sticky=NSEW) 
     nb = Notebook(panel, name='notebook')
     
     nb.enable_traversal()
     #nb.pack(fill=BOTH, expand=Y, padx=2, pady=3)
     nb.grid(row=0, column=0, sticky=NSEW)
     self._create_setup_tab(nb)
     self._create_analyze_tab(nb)
예제 #5
0
 def __init__(self):
   self.parent = Tkinter.Tk()
   Notebook.__init__(self, self.parent)
   #self.parent.title('Quora Analytics')
   self.parent.title('Quora Backup and Analytics')
   self.parent.wm_title('Quora Backup and Analytics')
   self.parent.grid_rowconfigure(0, weight=1)
   self.parent.grid_columnconfigure(0, weight=1)
   self.parent.resizable(True, True)
   self.grid_rowconfigure(0, weight=1)
   self.grid_columnconfigure(0, weight=1)
   self.crawler = QuoraCrawler(driver=QuoraCrawler.CHROME_DRIVER)
   self._add_frames()
   self.pack(fill='both', expand=True)
예제 #6
0
 def __init__(self):
     self.parent = Tkinter.Tk()
     Notebook.__init__(self, self.parent)
     # self.parent.title('Quora Analytics')
     self.parent.title("Quora Backup and Analytics")
     self.parent.wm_title("Quora Backup and Analytics")
     self.parent.grid_rowconfigure(0, weight=1)
     self.parent.grid_columnconfigure(0, weight=1)
     self.parent.resizable(True, True)
     self.grid_rowconfigure(0, weight=1)
     self.grid_columnconfigure(0, weight=1)
     self.crawler = QuoraCrawler(driver=QuoraCrawler.CHROME_DRIVER)
     self._add_frames()
     self.pack(fill="both", expand=True)
예제 #7
0
    def __init__(self, master, page_names=None, **kw):
        """Constructor arguments:

        page_names -- A list of strings, each will be the dictionary key to a
        page's widget, and the name displayed on the page's tab. Should be
        specified in the desired page order. The first page will be the default
        and first active page. If page_names is None or empty, the
        TabbedPageSet will be initialized empty.
        """
        Notebook.__init__(self, master, **kw)

        self.pages = {}
        page_names = page_names or ()
        for name in page_names:
            self.add_page(name)
예제 #8
0
    def __init__(self, master, page_names=None, **kw):
        """Constructor arguments:

        page_names -- A list of strings, each will be the dictionary key to a
        page's widget, and the name displayed on the page's tab. Should be
        specified in the desired page order. The first page will be the default
        and first active page. If page_names is None or empty, the
        TabbedPageSet will be initialized empty.
        """
        Notebook.__init__(self, master, **kw)

        self.pages = {}
        page_names = page_names or ()
        for name in page_names:
            self.add_page(name)
예제 #9
0
파일: VTab.py 프로젝트: maeddlae/keepit
    def __init__(self, parent, log, actions):
        '''
        Constructor
        '''
        Notebook.__init__(self, parent)
        self = styleNotebook(self)

        self.log = log
        self.actions = actions
        self.vsearch = None
        self.ventries = {}
        self.tabIds = {}
        self.vsearchDrawn = False
        self.overview = None
        self.bind("<<NotebookTabChanged>>", self.tabChanged)
        self.log.add(self.log.Info, __file__, "init")
예제 #10
0
    def __init__(self, master):
        master.minsize(width=1500, height=1500)
        root = Frame(master)
        root.pack(side=TOP, fill=BOTH)
        master.title('Stocks evaluation - Sandeep Joshi (FE520)')

        n = Notebook(root)
        n.enable_traversal()
        n.pack(fill=BOTH)
        self._create_stat_tab(n)
        self._create_help_tab(n)
        self.data = {}
        self.start = ''
        self.end = ''
        self.tickers = []
        self.tree
예제 #11
0
파일: view.py 프로젝트: adamchainz/bugjar
    def _setup_file_lists(self):

        self.file_notebook = Notebook(self.content, padding=(0, 5, 0, 5))
        self.content.add(self.file_notebook)

        self._setup_stack_frame_list()
        self._setup_breakpoint_list()
예제 #12
0
    def initUI(self):
        self.parent.title("Test")
        self.frameTab = Frame(self, relief=RAISED, borderwidth=1)
        self.frameTab.grid(row=3, column=0, columnspan=4)
        self.grid(row=0, column=0)
        self.frameTab.grid(row=0, column=0)
        self.note_book = Notebook(self.frameTab)
        self.specific_actions = ActionModulation.ActionModulation(self.note_book)
        self.note_book.add(self.specific_actions.getFrame(), text="specific actions")
        self.general_actions = GeneralActionModulation.GeneralActionModulation(self.note_book)
        self.note_book.add(self.general_actions.getFrame(), text="general actions")
        self.note_book.grid(row=0, column=0)

        self.frameButtons = Frame(self, relief=RAISED, borderwidth=1)
        self.frameButtons.grid(row=3, column=0, columnspan=4)
        self.buttonReset = Button(self.frameButtons, text="Reset")
        self.buttonReset.grid(row=0, column=0)
        self.buttonAbort = Button(self.frameButtons, text="Abort")
        self.buttonAbort.grid(row=0, column=1)
        self.buttonStop = Button(self.frameButtons, text="Stop")
        self.buttonStop.grid(row=0, column=2)
        self.buttonSendAction = Button(self.frameButtons, text="Send Action")
        self.buttonSendAction.grid(row=0, column=4)
        self.buttonSendEmotion = Button(self.frameButtons, text="Send Emotion")
        self.buttonSendEmotion.grid(row=0, column=5)
예제 #13
0
class NewActionModulation(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("Test")
        self.frameTab = Frame(self, relief=RAISED, borderwidth=1)
        self.frameTab.grid(row=3, column=0, columnspan=4)
        self.grid(row=0, column=0)
        self.frameTab.grid(row=0, column=0)
        self.note_book = Notebook(self.frameTab)
        self.specific_actions = ActionModulation.ActionModulation(self.note_book)
        self.note_book.add(self.specific_actions.getFrame(), text="specific actions")
        self.general_actions = GeneralActionModulation.GeneralActionModulation(self.note_book)
        self.note_book.add(self.general_actions.getFrame(), text="general actions")
        self.note_book.grid(row=0, column=0)

        self.frameButtons = Frame(self, relief=RAISED, borderwidth=1)
        self.frameButtons.grid(row=3, column=0, columnspan=4)
        self.buttonReset = Button(self.frameButtons, text="Reset")
        self.buttonReset.grid(row=0, column=0)
        self.buttonAbort = Button(self.frameButtons, text="Abort")
        self.buttonAbort.grid(row=0, column=1)
        self.buttonStop = Button(self.frameButtons, text="Stop")
        self.buttonStop.grid(row=0, column=2)
        self.buttonSendAction = Button(self.frameButtons, text="Send Action")
        self.buttonSendAction.grid(row=0, column=4)
        self.buttonSendEmotion = Button(self.frameButtons, text="Send Emotion")
        self.buttonSendEmotion.grid(row=0, column=5)

    def getCurrentTab(self):
        return self.note_book.index(self.note_book.select())

    def getFirstTab(self):
        return self.specific_actions

    def getSecondTab(self):
        return self.general_actions

    def getButtonSendAction(self):
        return self.buttonSendAction

    def getButtonSendEmotion(self):
        return self.buttonSendEmotion

    def getButtonReset(self):
        return self.buttonReset

    def getButtonAbort(self):
        return self.buttonAbort

    def getButtonStop(self):
        return self.buttonStop
예제 #14
0
class Tabs:
    def __init__(self, parent):
        self.root = Notebook(parent)
        self.frames = {}
        # self.frame1 = Frame(self.root)
        # self.root.add(self.frame1, text=label1)

        # self.frame2 = Frame(self.root)
        # self.root.add(self.frame2, text=label2)

        # self.frame3 = Frame(self.root)
        # self.root.add(self.frame3, text=label3)

    def add_frame(self, frame, label):
        # self.frames.append(frame)
        self.root.add(frame, text=label)
        self.frames[label] = frame

    def get_root(self):
        return self.root
예제 #15
0
 def _SetupCanvas(self):
     '''
     '''
     self.figure = Figure()
     self.figure.subplots_adjust(left=0.15, bottom=0.2)
     self.subfigure = self.figure.add_subplot(1,1,1)
     self.notebook = Notebook(self.toplevel)
     self.notebook.grid(row=1, column=1, rowspan=3, columnspan=3, sticky='nsew')
     self.canvas = FigureCanvasTkAgg(self.figure, master=self.toplevel)
     self.canvas.show()
     self.canvas.get_tk_widget().grid(row=0, column=0, rowspan=10)
예제 #16
0
파일: gui.py 프로젝트: JoeBartelmo/PyDetect
    def init_ui(self):
        #make resizable
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.notebook = Notebook(self)
        # define mainapp instance -- also manages above telemetry thread
        self.mainApplication = MainApplication(self, self.client_queue_cmd, self.client_queue_log, self.client_queue_telem, self.beam_gap_queue, self.destroyEvent, self.server_ip) 
        self.notebook.add(self.mainApplication, text = "Main")
        # define telemetry widgets
        self.monitor = Monitor(self, VisualConstants.MARS_PRIMARY(1))
        self.notebook.add(self.monitor, text = 'Monitor')
        self.notebook.grid(column = 0, row = 0, sticky = 'nsew')
        
        # menu -outside of notebook
        self.menu_ = TopMenu(self, '../gui/operations.json', self.client_queue_cmd, 'Commands')
        ### Add custom commands here
        self.menu_.add_menu_item('Reconnect to Cameras', self.mainApplication.start_streams, "View")
        self.menu_.add_menu_item('Left', self.mainApplication.focus_left, 'View/Camera Focus')
        self.menu_.add_menu_item('Center', self.mainApplication.focus_center, 'View/Camera Focus')
        self.menu_.add_menu_item('Right', self.mainApplication.focus_right, 'View/Camera Focus')
        self.menu_.add_menu_item('IBeam Display', self.beamGapGraph, 'View/Windows')
        self.menu_.add_menu_item('Toggle FOD Enabled', self.mainApplication.toggle_fod, 'View/Object Detection')
        self.menu_.add_menu_item('Set Ideal Images', self.mainApplication.define_ideal_images, 'View/Object Detection')
        ### 
        self.menu_.finalize_menu_items()
        self.config(menu=self.menu_)
        
        # start all operations here so we don't cause a hissyfit between tkinter and threads
        self.mainApplication.start_streams()
        #define telemetryThread
        self.tthread = TelemetryThread([self.mainApplication.telemetry_w, self.monitor], self.client_queue_telem, self.beam_gap_queue)
        self.tthread.start()

        # title and icon
        self.wm_title('Hyperloop Imaging Team')
        #this is garbage, i hate tkinter
        #self.img = ImageTk.PhotoImage(file='rit_imaging_team.xbm')
        #self.tk.call('wm', 'iconphoto', self._w, self.img)
        #self.iconbitmap('@rit_imaging_team.xbm')
        #call destroyCallback on clicking X
        self.protocol('WM_DELETE_WINDOW', self.destroyCallback)
        

        #assign dimensions and locatin on screen
        width = 900
        height = 500
 
        x = (self.winfo_screenwidth() // 2) - (width // 2)
        y = (self.winfo_screenheight() // 2) - (height // 2)
        self.geometry('{}x{}+{}+{}'.format(width, height, x, y))
        
        self.update()
예제 #17
0
def init_UI():
    '''create tabs and required content'''

    # initialize main window
    main = Tk()
    main.title('data2knowledge')

    # component for 'tab' functionality
    n = Notebook(main)

    # initialize the various tabs
    EnrichTab(n, 'Enrich', main)
    ProcessTab(n, 'Process', main)
    MergeTab(n, 'Merge', main)
    LearningTab(n, 'Learn', main)
    ReportTab(n, 'Report', main)
    AboutTab(n, 'About', main)

    # finish up, return UI
    n.pack()
    return main
def init_UI():
	'''create tabs and required content'''

	# initialize main window
	main = Tk()
	main.title('data2knowledge')

	# component for 'tab' functionality
	n = Notebook(main)

	# initialize the various tabs
	EnrichTab(n, 'Enrich', main)
	ProcessTab(n, 'Process', main)
	MergeTab(n, 'Merge', main)
	LearningTab(n, 'Learn', main)
	ReportTab(n, 'Report', main)
	AboutTab(n, 'About', main)

	# finish up, return UI
	n.pack()
	return main
예제 #19
0
class Tabs:
	def __init__(self, parent):
		self.root = Notebook(parent)
		self.frames = {}
		# self.frame1 = Frame(self.root)
		# self.root.add(self.frame1, text=label1)

		# self.frame2 = Frame(self.root)
		# self.root.add(self.frame2, text=label2)

		# self.frame3 = Frame(self.root)
		# self.root.add(self.frame3, text=label3)


	def add_frame(self, frame, label):
		# self.frames.append(frame)
		self.root.add(frame, text=label)
		self.frames[label] = frame

	def get_root(self):
		return self.root
예제 #20
0
    def build_notebook(self):

        banner = os.path.join("tkgui", "resources", "art", "banner.png")
        tkimage = ImageTk.PhotoImage(file=banner)
        self.banner = Label(self,
                            image=tkimage,
                            justify=CENTER,
                            height=400,
                            bg="#afc8e1")
        self.banner.photo = tkimage
        self.banner.pack(side=LEFT, fill=BOTH, expand=True)

        self.noteBook = Notebook(self, style="TNotebook")
예제 #21
0
파일: control.py 프로젝트: sychov/conditer
def show_control(master, data):
    """Выводит блокнот управления с пятью закладками"""

    if data.is_restart:
        reload(control_a)
        reload(control_b)
        reload(control_c)
        reload(control_d)
        reload(control_e)
        reload(control_f)

    from control_a import show_goods
    from control_b import show_calc
    from control_c import show_sales_goods
    from control_d import show_sales
    from control_e import show_others
    from control_f import show_plus


    def tab_changes(tab):
        """функция, срабатывающая при нажатии закладок переключения
        между правыми (основными) фреймами"""

        window_names = controlTabs.tabs()
        index = window_names.index(controlTabs.select())

        if not FLAGS[index]:
            CONTROL[index](workArea[index], data)                   #нужна ли эта дата?
            FLAGS[index] = True
        else:
            CONTROL[index].renew()


    CONTROL = (show_goods, show_calc, show_sales_goods,
               show_sales, show_others, show_plus)

    FLAGS = [False, False, False, False, False, False]

    heads = (u' Товары ', u' Калькуляции ',
             u' Акционные товары ', u' Акционные цены ',
             u' Категории, скидки, причины списания ', u' Дополнительно ')

    workArea = []

    controlTabs = Notebook(master)
    for q in range (6):
        frame = Canvas(controlTabs, relief=GROOVE, highlightthickness=0)
        if USE_BACKGROUND:
            frame.create_image(0,0, anchor='nw', image=data.photo)
        controlTabs.add(frame, text=heads[q])
        workArea.append(frame)
    controlTabs.pack(side=TOP, fill=BOTH, expand=YES)
    controlTabs.bind('<<NotebookTabChanged>>', tab_changes)
    Style().configure("TNotebook.Tab", font=('Verdana', FONT_SIZE))
예제 #22
0
class ConverterFrame(Frame):
    def __init__(self, converter, master=None):
        Frame.__init__(self, master)

        master.title("Ai Variable tool")

        self.converter = converter

        self.grid(row=0, sticky=(tk.N + tk.E + tk.W + tk.S))
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.tabbedPane = Notebook(self, name="tabbed-pane")
        self.tabbedPane.grid(row=0,
                             column=0,
                             sticky=(tk.N + tk.E + tk.W + tk.S))

        self.btnSave = tk.Button(self,
                                 text="Guardar",
                                 command=self.btnSaveCallback)
        self.btnSave.grid(row=1, column=0, sticky=(tk.N + tk.E + tk.W + tk.S))

        self.rawTextPanel = RawTextPane(self.tabbedPane)
        self.rawTextPanel.grid(row=0,
                               column=0,
                               sticky=(tk.N + tk.E + tk.W + tk.S))

        self.numbersPanel = NumbersPane(self.tabbedPane)
        self.numbersPanel.grid(row=0,
                               column=0,
                               sticky=(tk.N + tk.E + tk.W + tk.S))

        self.tabbedPane.add(self.numbersPanel, text="Series de numeros")
        self.tabbedPane.add(self.rawTextPanel, text="Texto en crudo")

        self.panels = [self.numbersPanel, self.rawTextPanel]

    def btnSaveCallback(self):
        filename = tkFileDialog.asksaveasfilename(
            initialdir=".",
            title="Select file",
            filetypes=(("Xml files", "*.xml"), ("All files", "*.*")))

        current_idx = self.tabbedPane.index("current")
        work_text = self.panels[current_idx].getText()

        self.converter.convert(work_text)
        if not self.converter.save(filename):
            tkMessageBox.showerror("Error",
                                   "El archivo no ha sido almacenado.")
        else:
            tkMessageBox.showinfo(
                "Exito", "El archivo ha sido almacenado adecuadamente.")
예제 #23
0
    def configWidgetsGetApps(
        self
    ):  # Configura todos os widgets que pertencem ao frame que mostra todos os apps e forms
        self.frameGetApps = Frame(self.frameBody)

        self.frameAbasGetApps = Notebook(self.frameGetApps)
        self.frameAbasGetApps.pack(side=TOP, fill=BOTH)

        frameApp = Frame(self.frameAbasGetApps)
        frameInfoApp = Frame(frameApp)
        frameInfoApp.pack(side=TOP, fill=BOTH)
        frameFieldsApp = Frame(frameApp)
        frameFieldsApp.pack(side=TOP, fill=BOTH)

        for idApp, nomeApp, pathImage in self.db.getAllInfoForms(
                "id", "nome_formulario", "caminho_imagem"):
            image = renderPhoto(pathImage, (35, 35))
            self.frameAbasGetApps.add(frameApp,
                                      compound=LEFT,
                                      image=image,
                                      text=nomeApp,
                                      sticky=W + E + N + S)
            break
예제 #24
0
def main():
    root = tk.Tk()
    root.geometry("600x400+150+150")
    app = frame_make(root)

    fileloc = "list.txt"  # Local directory file
    #Format: [short name],[long name],[path to sh file]

    global termID, frameID, winID 
    termID = []     # PIDs in Terminals
    frameID = []    # Frame ID
    winID = []      # Window IDs of the Terminal windows
    gameID = []     # List of short names as we add them

    note = Notebook(root)
    with open(fileloc, 'rb') as csvfile:
        read = csv.reader(csvfile, delimiter=',', quotechar='|')
        for i, row in enumerate(read):
            if len(row) > 0:
                shortname, longname, command = map(str.strip, row)

                frameID.append(tk.Frame(note))
                note.add(frameID[i], text=shortname)
                               
                lbutton = 'Launch: ' + longname
                launch_command = lambda com, j: lambda : send_launch_game(com, j)
                lg = tk.Button(frameID[i],
                          text=lbutton,
                          command=launch_command(command, i))
                #kg = tk.Button(frameID[i],
                #          text="Stop Game",
                #          command=lambda: send_kill_game(wip,i))

                gameID.append(shortname)
                
                lg.pack(in_=frameID[i])
                #kg.pack(in_=frameID[i])

                term = tk.Frame(frameID[i], height=300, width=500)
                term.pack(fill=tk.BOTH,side='top', expand=tk.YES)
                
                wip = term.winfo_id()
                winID.append(wip)

    note.pack(fill='both', expand=True)            
    tk.Button(root, text='Refresh List',command= lambda : refresh_tabs(note, fileloc, gameID)).pack(side='left')
    tk.Button(root, text='Exit', command=root.destroy).pack(side='right')
    #tk.Button(root, text='Exit',command=destroy_all(root)).pack(side='right')
    
    root.mainloop()
    
    send_kill_all() #At end of program, kill all open terminal processes
예제 #25
0
    def __init__(self, master):
        master.minsize(width=1500, height=1500)
        root = Frame(master)
        root.pack(side=TOP, fill=BOTH)
        master.title('Stocks evaluation - Sandeep Joshi (FE520)')

        n = Notebook(root)
        n.enable_traversal()
        n.pack(fill=BOTH)
        self._create_stat_tab(n)
        self._create_help_tab(n)
        self.data = {}
        self.start = ''
        self.end = ''
        self.tickers = []
        self.tree
예제 #26
0
    def __init__(self, master):
        self.fname = ""
        self.t1 = StringVar()
        self.t2 = StringVar()
        self.t3 = StringVar()
        self.t4 = StringVar()
        self.var1 = StringVar()
        self.var2 = StringVar()
        self.var3 = StringVar()
        self.var4 = StringVar()

        mymaster = Frame(master, name='mymaster')  # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window
        #master.minsize(width=900, height=900)
        #master.maxsize(width=550, height=350)
        #end

        #title of window
        master.title("Airserv-ng")
        #end

        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont = tkFont.Font(family="Helvetica",
                                      size=15,
                                      underline=True)
        self.myfontnew = tkFont.Font(family="Helvetica",
                                     size=11,
                                     underline=True)
        #end

        nb = Notebook(mymaster, name='nb')  # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3)  # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb, name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1")  # add tab to Notebook

        # repeat for each tab
        self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")
        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        #End
        #frame content 7
        Label(self.frame_content7,
              text='Aigraph-ng',
              font=self.headerfont,
              bg="white",
              padx=10,
              pady=10).grid(row=0, column=0)
        btndetect = Button(self.frame_content7,
                           text='Detect',
                           command=self.canvas_detect,
                           height=2,
                           width=15,
                           font=self.customFont).grid(row=1,
                                                      column=0,
                                                      padx=5,
                                                      pady=5)

        btndbrowse = Button(self.frame_content7,
                            text='Attach File',
                            command=self.browse_file,
                            height=2,
                            width=15,
                            font=self.customFont).grid(row=3,
                                                       column=0,
                                                       padx=5,
                                                       pady=5)
        self.lilnew1 = Listbox(self.frame_content7,
                               bg="black",
                               fg="white",
                               font=self.myfont,
                               selectmode=SINGLE,
                               width=30,
                               height=15)
        self.lilnew1.grid(row=1, column=1, rowspan=3)
        #End

        Label(self.frame_content,
              text='Airserv-ng',
              font=self.headerfont,
              bg="white",
              padx=10,
              pady=10).grid(row=0, column=0)
        Label(self.frame_content,
              text='Options :',
              font=self.myfontnew,
              bg="white").grid(row=1, column=1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5,
              text='Edit Command From Here',
              font=self.myfontnew,
              bg="white",
              justify=LEFT).grid(row=0, column=0)
        TextCommandBox = Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output = Text(self.frame_content5,
                           bg="black",
                           fg="white",
                           font=self.myfont,
                           height=15,
                           width=30)
        self.output.grid(row=0, column=1, padx=50, pady=5, rowspan=3)
        btnsubmit = Button(self.frame_content5,
                           width=15,
                           height=2,
                           text="Get Result",
                           command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear = Button(self.frame_content5,
                          width=15,
                          height=2,
                          text="Clear Output",
                          command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "-p", \
                 onvalue="-p",offvalue="", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var1)
        self.C1.grid(row=2, column=0, padx=5, pady=5)
        self.t1 = Text(self.frame_content, height=1, width=20)
        self.t1.grid(row=2, column=1, padx=5, pady=5)
        l1 = Label(self.frame_content,
                   text=': TCP port to listen on. Defaults to 666.',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=2, column=2, padx=5, pady=5)

        self.C2 = Checkbutton(self.frame_content, text = "-d", \
                 onvalue = "-d", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var2)
        self.C2.grid(row=3, column=0, padx=5, pady=5)
        self.t2 = Text(self.frame_content, height=1, width=20)
        self.t2.grid(row=3, column=1, padx=5, pady=5)
        l2 = Label(self.frame_content,
                   text=': wifi device to serve.',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=3, column=2, padx=5, pady=5)

        self.C3 = Checkbutton(self.frame_content, text = "-c", \
                 onvalue = "-c", offvalue ="", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row=4, column=0, padx=5, pady=5)
        self.t3 = Text(self.frame_content, height=1, width=20)
        self.t3.grid(row=4, column=1, padx=5, pady=5)
        l3 = Label(self.frame_content,
                   text=':   Channel to start on.',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=4, column=2, padx=5, pady=5)

        self.C4 = Checkbutton(self.frame_content, text = "-v", \
                 onvalue = "-v", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row=5, column=0, padx=5, pady=5)
        self.t4 = Text(self.frame_content, height=1, width=20)
        self.t4.grid(row=5, column=1, padx=5, pady=5)
        l4 = Label(self.frame_content,
                   text=': debug level.',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=5, column=2, padx=5, pady=5)
예제 #27
0
def report_sell(master, from_date=None, to_date=None,  cathegory=-1,
    from_check=None, to_check=None, item=None, discount=None):
    """Создает и выводи на экран окно с отчетом по продажам, составленным на
    основании заданных фильтров"""


    def press(index):
        """функция, срабатывающая при нажатии кнопок переключения
        между видами сортировок. Переключает вкладки в блокноте"""

        window_names = tabs.tabs()
        tabs.select(window_names[index])


    def make_query_sell(from_date=None, to_date=None,  cathegory=-1,
        from_check=None, to_check=None, item=None, discount=None):
        """Возвращает кортеж запросов для последующего использования при
        составлении отчета по продажам"""

        select = queries.report_sell_query()

        if cathegory <> -1:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.goods.cathegory == cathegory:
                        new_select.append(element)
                select[q] = new_select

        if item:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.goods == item:
                        new_select.append(element)
                select[q] = new_select

        if from_check and to_check:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if (element.check.id >= from_check) and (element.check.id
                                                                   <= to_check):
                        new_select.append(element)
                select[q] = new_select

        elif from_check:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.check.id >= from_check:
                        new_select.append(element)
                select[q] = new_select

        elif to_check:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.check.id <= to_check:
                        new_select.append(element)
                select[q] = new_select

        if discount <> None:
            if discount:
                for q in range(len(select)):
                    new_select = []
                    for element in select[q]:
                        if element.discount:
                            new_select.append(element)
                    select[q] = new_select
            else:
                for q in range(len(select)):
                    new_select = []
                    for element in select[q]:
                        if not element.discount:
                            new_select.append(element)
                    select[q] = new_select

        if from_date and to_date:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if (element.check.date_time >= from_date) and \
                       (element.check.date_time <= to_date + timedelta(days=1)):
                        new_select.append(element)
                select[q] = new_select

        elif from_date:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.check.date_time >= from_date:
                        new_select.append(element)
                select[q] = new_select

        elif to_date:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.check.date_time <= to_date + timedelta(days=1):
                        new_select.append(element)
                select[q] = new_select

        return select


    def show(frame, iterator):
        """Выводит на экран выборку, заданную в iterator"""

        scrollbar = Scrollbar(frame)
        tree = Treeview(frame, selectmode='none', padding=3,
                                style='Custom.Treeview', height=REPORT_HEIGHT,
                                yscrollcommand=scrollbar.set)
        tree.pack(side=LEFT, fill=BOTH, expand=YES)
        scrollbar.config(command=tree.yview)
        scrollbar.pack(side=LEFT, fill=Y)

        tree.tag_configure('1', font=('Verdana', FONT_SIZE_REPORT))
        tree.tag_configure('2', font=('Verdana', FONT_SIZE_REPORT),
                                                           background='#f5f5ff')

        Style().configure('Custom.Treeview', rowheight=FONT_SIZE_REPORT*2)

        columns = ['#' + str(x + 1) for x in range(8)]
        tree.configure(columns=columns)

        for q in range(len(header)):
            tree.heading('#%d' % (q + 1), text=header[q], anchor='w')
            tree.column('#%d' % (q + 1), width=REPORT_SCALE * col_width[q + 1],
                                                                     anchor='w')
        tree.heading('#0', text='', anchor='w')
        tree.column('#0', width=0, anchor='w', minwidth=0)

        flag = True
        summ = 0
        for item in iterator:

            value = item.quantity * item.price * (100 - item.discount) / 100
            summ += value

            col = []
            col.append(add_s(item.check.id))
            col.append(add_s(item.goods.cathegory.name))
            col.append(add_s(item.goods.name))
            col.append(add_s(item.quantity))
            col.append(add_s(item.discount) +'%' if item.discount else ' -- ')
            col.append(add_s(u'%6.2f грн.' % value))
            col.append(add_s(item.check.date_time.strftime('%d.%m.%Y')))
            col.append(add_s(item.check.date_time.time())[:8])

            flag = not flag
            if flag:
                tree.insert('', 'end', text='', values=col, tag='2')
            else:
                tree.insert('', 'end', text='', values=col, tag='1')

        return summ

    # --------------------------------------------#

    tl = Toplevel(master)
    tl.title(u'Отчет по продажам')

    bottom = Frame(tl, relief=SUNKEN)
    bottom.pack(side=BOTTOM, fill=X)

    showArea = []
    tabs = Notebook(tl, style='Hidden.TNotebook')
    for q in range (4):
        frame = Frame(tabs,  height=REPORT_HEIGHT)
        tabs.add(frame, text='')
        showArea.append(frame)
    tabs.pack(side=TOP, fill=BOTH, expand=YES)
    Style().layout('Hidden.TNotebook.Tab', '')

    header = [u'Чек', u'Категория', u'Товар', u'Кол-во', u'Скидка',
                u'Стоимость', u'Дата', u'Время']

    col_width = (0, 10, 15, 38, 10, 10, 20, 16, 16)


    #---------------------TEST-----------
##    cathegory = list(Cathegory.select())[1]
##    item = Assortiment.get(Assortiment.name == u'Солнышко')
##    from_check = 12
##    to_check = 16
##    discount = False
##    from_date = datetime(year=2014, month=9, day=25)
##    to_date = datetime(year=2014, month=9, day=25)
    #------------------------------------


    query = make_query_sell(from_date, to_date, cathegory, from_check, to_check,
                                                                 item, discount)
    for q in range(len(query)):
        summ = show(showArea[q], query[q])

    Button(bottom, text=u'Сортировка\nпо чеку', command=lambda: press(0)).pack(
                                    side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Сортировка\nпо категории', command=lambda: press(1)
                             ).pack(side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Сортировка\nпо товару', command=lambda:press(2)).pack(
                                    side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Сортировка\nпо дате', command=lambda: press(3)).pack(
                                    side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)


    Button(bottom, text=u'Экспорт в\nMS Excel').pack(
                                   side=RIGHT, padx=REPORT_PAD, pady=REPORT_PAD)

    Label(bottom,
          text=u'Итого: %.2f грн.' % summ,
          font=('Lucida Console', FONT_SIZE_BIG,'bold')).pack(side=RIGHT,
                                               padx=REPORT_PAD, pady=REPORT_PAD)
    tl.focus_set()
예제 #28
0
    def __init__(self, master):
        
	self.fname=""
        #global variables
        self.t1=StringVar()
        self.t2=StringVar()
        self.t3=StringVar()
        self.t4=StringVar()
        self.t5=StringVar()
        self.t6=StringVar()
        self.t7=StringVar()
        self.t8=StringVar()
        self.t9=StringVar()
        self.t10=StringVar()
        self.t11=StringVar()
        self.t12=StringVar()
        self.t13=StringVar()
        self.t14=StringVar()
        self.t15=StringVar()
        self.t16=StringVar()
        self.t17=StringVar()
        self.t18=StringVar()
        self.t19=StringVar()
        self.t20=StringVar()
        self.t21=StringVar()
        self.t22=StringVar()
        self.t23=StringVar()
        self.t24=StringVar()
        self.t25=StringVar()
        self.t26=StringVar()
        self.t27=StringVar()
        self.t28=StringVar()
        self.t29=StringVar()
        self.t30=StringVar()
        self.t31=StringVar()
        self.t32=StringVar()
        self.t33=StringVar()
        self.t34=StringVar()
        
        self.var1=StringVar()
        self.var2=StringVar()
        self.var3=StringVar()
        self.var4=StringVar()
        self.var5=StringVar()
        self.var6=StringVar()
        self.var7=StringVar()
        self.var8=StringVar()
        self.var9=StringVar()
        self.var10=StringVar()
        self.var11=StringVar()
        self.var12=StringVar()
        self.var13=StringVar()
        self.var14=StringVar()
        self.var15=StringVar()
        self.var16=StringVar()
        self.var17=StringVar()
        self.var18=StringVar()
        self.var19=StringVar()
        self.var20=StringVar()
        self.var21=StringVar()
        self.var22=StringVar()
        self.var23=StringVar()
        self.var24=StringVar()
        self.var25=StringVar()
        self.var26=StringVar()
        self.var27=StringVar()
        self.var28=StringVar()
        self.var29=StringVar()
        self.var30=StringVar()
        self.var31=StringVar()
        self.var32=StringVar()
        self.var33=StringVar()
        self.var34=StringVar()
        #end
        
        mymaster = Frame(master, name='mymaster') # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window    
        #master.minsize(width=900, height=900)
        #master.maxsize(width=650, height=385)
        #end
        
        #title of window
        master.title("Airbase-ng")
        #end
        
        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont=tkFont.Font(family="Helvetica", size=15,underline = True)
        self.myfontnew=tkFont.Font(family="Helvetica", size=11,underline = True)
        #end
        
        
       
        nb = Notebook(mymaster, name='nb') # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3) # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1") # add tab to Notebook
    
        # repeat for each tab
        self.frame_content2 = Frame(nb, name='frame_content2', bg="white")
        nb.add(self.frame_content2, text="Filter-2")
        self.frame_content3 = Frame(nb, name='frame_content3', bg="white")
        nb.add(self.frame_content3, text="Filter-3")
        self.frame_content4 = Frame(nb, name='frame_content4', bg="white")
        nb.add(self.frame_content4, text="Filter-4")
        self.frame_content6 = Frame(nb, name='frame_content6', bg="white")
        nb.add(self.frame_content6, text="Filter-5")
	self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")
        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        
        #End
	#frame content 7
	Label(self.frame_content7, text = 'Airbase-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        btndetect=Button(self.frame_content7, text = 'Detect', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 1, column = 0, padx = 5, pady = 5)
		
	btndbrowse=Button(self.frame_content7, text = 'Attach File', command =self.browse_file, height=2, width=15, font=self.customFont).grid(row = 3, column = 0, padx = 5, pady = 5)	
	self.lilnew1=Listbox(self.frame_content7,bg="black", fg="white", font=self.myfont, selectmode=SINGLE, width=30, height=15)
        self.lilnew1.grid(row = 1, column = 1, rowspan=3)
	#End        
	
        Label(self.frame_content, text = 'Airbase-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content, text = 'Options :',font=self.myfontnew, bg="white").grid(row = 1, column = 1)
        #command Listbox
        Label(self.frame_content5, text = 'Edit Command From Here',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 0, column = 0)
        TextCommandBox=Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output=Text(self.frame_content5,bg="black", fg="white", font=self.myfont, height=20, width=42)
        self.output.grid(row = 0, column = 1, padx=50, pady=5, rowspan=3)
        btnsubmit=Button(self.frame_content5, width=15, height=2, text="Get Result", command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear=Button(self.frame_content5, width=15, height=2, text="Clear Output", command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "-a", \
                 onvalue = "-a", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var1)
        self.C1.grid(row = 2, column = 0, padx = 5, pady = 5)
        self.t1=Text(self.frame_content,height=1,width = 20)
        self.t1.grid(row = 2, column = 1, padx = 5, pady = 5)
        l1=Label(self.frame_content, text = ': set Access Point MAC address',font=self.myfont, bg="white", justify=LEFT).grid(row = 2, column = 2, padx = 5, pady = 5)
        
        self.C2 = Checkbutton(self.frame_content, text = "-i", \
                 onvalue = "-i", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var2)
        self.C2.grid(row = 3, column = 0, padx = 5, pady = 5)
        self.t2=Text(self.frame_content,height=1,width = 20)
        self.t2.grid(row = 3, column = 1, padx = 5, pady = 5)
        l2=Label(self.frame_content, text = ': capture packets from this interface',font=self.myfont, bg="white", justify=LEFT).grid(row = 3, column = 2, padx = 5, pady = 5)
        
        self.C3 = Checkbutton(self.frame_content, text = "-w", \
                 onvalue = "-w", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row = 4, column = 0, padx = 5, pady = 5)
        self.t3=Text(self.frame_content,height=1,width = 20)
        self.t3.grid(row = 4, column = 1, padx = 5, pady = 5)
        l3=Label(self.frame_content, text = ': use this WEP key to encrypt/decrypt packets',font=self.myfont, bg="white", justify=LEFT).grid(row = 4, column = 2, padx = 5, pady = 5)
        
        self.C4 = Checkbutton(self.frame_content, text = "-h", \
                 onvalue = "-h", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row = 5, column = 0, padx = 5, pady = 5)
        self.t4=Text(self.frame_content,height=1,width = 20)
        self.t4.grid(row = 5, column = 1, padx = 5, pady = 5)
        l4=Label(self.frame_content, text = ': source mac for MITM mode',font=self.myfont, bg="white", justify=LEFT).grid(row = 5, column = 2, padx = 5, pady = 5)
        
        self.C5 = Checkbutton(self.frame_content, text = "-f", \
                 onvalue = "-f", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var5)
        self.C5.grid(row = 6, column = 0, padx = 5, pady = 5)
        self.t5=Text(self.frame_content,height=1,width = 20)
        self.t5.grid(row = 6, column = 1, padx = 5, pady = 5)
        l5=Label(self.frame_content, text = ': disallow specified client MACs (default: allow)',font=self.myfont, bg="white", justify=LEFT).grid(row = 6, column = 2, padx = 5, pady = 5)
        
        self.C6 = Checkbutton(self.frame_content, text = "-W", \
                 onvalue = "-W", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var6)
        self.C6.grid(row = 7, column = 0, padx = 5, pady = 5)
        self.t6=Text(self.frame_content,height=1,width = 20)
        self.t6.grid(row = 7, column = 1, padx = 5, pady = 5)
        l6=Label(self.frame_content, text = ': [don\'t] set WEP flag in beacons 0|1 (default: auto)',font=self.myfont, bg="white", justify=LEFT).grid(row = 7, column = 2, padx = 5, pady = 5)
        
        self.C7 = Checkbutton(self.frame_content, text = "-q", \
                 onvalue = "-q", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var7)
        self.C7.grid(row = 8, column = 0, padx = 5, pady = 5)
        self.t7=Text(self.frame_content,height=1,width = 20)
        self.t7.grid(row = 8, column = 1, padx = 5, pady = 5)
        l7=Label(self.frame_content, text = ': quiet (do not print statistics)',font=self.myfont, bg="white", justify=LEFT).grid(row = 8, column = 2, padx = 5, pady = 5)
        
        self.C8 = Checkbutton(self.frame_content2, text = "-v", \
                 onvalue = "-v", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var8)
        self.C8.grid(row = 9, column = 0, padx = 5, pady = 5)
        self.t8=Text(self.frame_content2,height=1,width = 20)
        self.t8.grid(row = 9, column = 1, padx = 5, pady = 5)
        l8=Label(self.frame_content2, text = ':  verbose (print more messages) (long --verbose)',font=self.myfont, bg="white", justify=LEFT).grid(row = 9, column = 2, padx = 5, pady = 5)
        
        self.C9 = Checkbutton(self.frame_content2, text = "-M", \
                 onvalue = "-M", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var9)
        self.C9.grid(row = 10, column = 0, padx = 5, pady = 5)
        self.t9=Text(self.frame_content2,height=1,width = 20)
        self.t9.grid(row = 10, column = 1, padx = 5, pady = 5)
        l9=Label(self.frame_content2, text = ': M-I-T-M between [specified] clients and bssids',font=self.myfont, bg="white", justify=LEFT).grid(row = 10, column = 2, padx = 5, pady = 5)
        
        Label(self.frame_content2, text = 'Airbase-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        
        self.C10 = Checkbutton(self.frame_content2, text = "-A", \
                 onvalue = "-A", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var10)
        self.C10.grid(row = 11, column = 0, padx = 5, pady = 5)
        self.t10=Text(self.frame_content2,height=1,width = 20)
        self.t10.grid(row = 11, column = 1, padx = 5, pady = 5)
        l10=Label(self.frame_content2, text = ': Ad-Hoc Mode (allows other clients to peer) (long --ad-hoc)',font=self.myfont, bg="white", justify=LEFT).grid(row = 11, column = 2, padx = 5, pady = 5)
        
        self.C11 = Checkbutton(self.frame_content2, text = "-Y", \
                 onvalue = "-Y", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var11)
        self.C11.grid(row = 12, column = 0, padx = 5, pady = 5)
        self.t11=Text(self.frame_content2,height=1,width = 20)
        self.t11.grid(row = 12, column = 1, padx = 5, pady = 5)
        l11=Label(self.frame_content2, text = ': external packet processing',font=self.myfont, bg="white", justify=LEFT).grid(row = 12, column = 2, padx = 5, pady = 5)
        
        self.C12 = Checkbutton(self.frame_content2, text = "-c", \
                 onvalue = "-c", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var12)
        self.C12.grid(row = 13, column = 0, padx = 5, pady = 5)
        self.t12=Text(self.frame_content2,height=1,width = 20)
        self.t12.grid(row = 13, column = 1, padx = 5, pady = 5)
        l12=Label(self.frame_content2, text = ': sets the channel the AP is running on',font=self.myfont, bg="white", justify=LEFT).grid(row = 13, column = 2, padx = 5, pady = 5)
        
        self.C13 = Checkbutton(self.frame_content2, text = "-X", \
                 onvalue = "-X", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var13)
        self.C13.grid(row = 14, column = 0, padx = 5, pady = 5)
        self.t13=Text(self.frame_content2,height=1,width = 20)
        self.t13.grid(row = 14, column = 1, padx = 5, pady = 5)
        l13=Label(self.frame_content2, text = ': hidden ESSID (long --hidden)',font=self.myfont, bg="white", justify=LEFT).grid(row = 14, column = 2, padx = 5, pady = 5)
        
        self.C14 = Checkbutton(self.frame_content2, text = "-s", \
                 onvalue = "-s", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var14)
        self.C14.grid(row = 15, column = 0, padx = 5, pady = 5)
        self.t14=Text(self.frame_content2,height=1,width = 20)
        self.t14.grid(row = 15, column = 1, padx = 5, pady = 5)
        l14=Label(self.frame_content2, text = ': force shared key authentication',font=self.myfont, bg="white").grid(row = 15, column = 2, padx = 5, pady = 5)
        
        
        Label(self.frame_content3, text = 'Airbase-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content3, text = 'Filter Options :',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 16, column = 1)
        
        self.C15 = Checkbutton(self.frame_content3, text = "-S", \
                 onvalue = "-S", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var15)
        self.C15.grid(row = 17, column = 0, padx = 5, pady = 5)
        self.t15=Text(self.frame_content3,height=1,width = 20)
        self.t15.grid(row = 17, column = 1, padx = 5, pady = 5)
        l15=Label(self.frame_content3, text = ': set shared key challenge length (default: 128)',font=self.myfont, bg="white", justify=LEFT).grid(row = 17, column = 2, padx = 5, pady = 5)
        
        self.C16 = Checkbutton(self.frame_content3, text = "-L", \
                 onvalue = "-L", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var16)
        self.C16.grid(row = 18, column = 0, padx = 5, pady = 5)
        self.t16=Text(self.frame_content3,height=1,width = 20)
        self.t16.grid(row = 18, column = 1, padx = 5, pady = 5)
        l16=Label(self.frame_content3, text = ': Caffe-Latte attack (long --caffe-latte)',font=self.myfont, bg="white", justify=LEFT).grid(row = 18, column = 2, padx = 5, pady = 5)
        
        self.C17 = Checkbutton(self.frame_content3, text = "-N", \
                 onvalue = "-N", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var17)
        self.C17.grid(row = 19, column = 0, padx = 5, pady = 5)
        self.t17=Text(self.frame_content3,height=1,width = 20)
        self.t17.grid(row = 19, column = 1, padx = 5, pady = 5)
        l17=Label(self.frame_content3, text = ':  creates arp request against wep client (long cfrag)',font=self.myfont, bg="white", justify=LEFT).grid(row = 19, column = 2, padx = 5, pady = 5)
    
        
        self.C18 = Checkbutton(self.frame_content3, text = "-x", \
                 onvalue = "-x", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var18)
        self.C18.grid(row = 21, column = 0, padx = 5, pady = 5)
        self.t18=Text(self.frame_content3,height=1,width = 20)
        self.t18.grid(row = 21, column = 1, padx = 5, pady = 5)
        l18=Label(self.frame_content3, text = ': number of packets per second (default: 100)',font=self.myfont, bg="white", justify=LEFT).grid(row = 21, column = 2, padx = 5, pady = 5)
        
        self.C19 = Checkbutton(self.frame_content3, text = "-y", \
                 onvalue = "-y", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var19)
        self.C19.grid(row = 22, column = 0, padx = 5, pady = 5)
        self.t19=Text(self.frame_content3,height=1,width = 20)
        self.t19.grid(row = 22, column = 1, padx = 5, pady = 5)
        l19=Label(self.frame_content3, text = ': disables responses to broadcast probes',font=self.myfont, bg="white", justify=LEFT).grid(row = 22, column = 2, padx = 5, pady = 5)
        
        Label(self.frame_content4, text = 'Airbase-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        
        self.C20 = Checkbutton(self.frame_content4, text = "--o", \
                 onvalue = "--o", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var20)
        self.C20.grid(row = 23, column = 0, padx = 5, pady = 5)
        self.t20=Text(self.frame_content4,height=1,width = 20)
        self.t20.grid(row = 23, column = 1, padx = 5, pady = 5)
        l20=Label(self.frame_content4, text = ': set all WPA,WEP,open tags. can\'t be used with -z & -Z',font=self.myfont, bg="white", justify=LEFT).grid(row = 23, column = 2, padx = 5, pady = 5)
        
        self.C21 = Checkbutton(self.frame_content4, text = "-z", \
                 onvalue = "-z", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var21)
        self.C21.grid(row = 24, column = 0, padx = 5, pady = 5)
        self.t21=Text(self.frame_content4,height=1,width = 20)
        self.t21.grid(row = 24, column = 1, padx = 5, pady = 5)
        l21=Label(self.frame_content4, text = ':  sets WPA1 tags. 1=WEP40 2=TKIP 3=WRAP 4=CCMP 5=WEP104',font=self.myfont, bg="white", justify=LEFT).grid(row = 24, column = 2, padx = 5, pady = 5)
        
        self.C22 = Checkbutton(self.frame_content4, text = "-Z", \
                 onvalue = "-Z", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var22)
        self.C22.grid(row = 25, column = 0, padx = 5, pady = 5)
        self.t22=Text(self.frame_content4,height=1,width = 20)
        self.t22.grid(row = 25, column = 1, padx = 5, pady = 5)
        l22=Label(self.frame_content4, text = ':  same as -z, but for WPA2',font=self.myfont, bg="white", justify=LEFT).grid(row = 25, column = 2, padx = 5, pady = 5)
        
        self.C23 = Checkbutton(self.frame_content4, text = "-V", \
                 onvalue = "-V", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var23)
        self.C23.grid(row = 26, column = 0, padx = 5, pady = 5)
        self.t23=Text(self.frame_content4,height=1,width = 20)
        self.t23.grid(row = 26, column = 1, padx = 5, pady = 5)
        l23=Label(self.frame_content4, text = ':  fake EAPOL 1=MD5 2=SHA1 3=auto',font=self.myfont, bg="white", justify=LEFT).grid(row = 26, column = 2, padx = 5, pady = 5)
        
        self.C24 = Checkbutton(self.frame_content4, text = "-F", \
                 onvalue = "-F", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var24)
        self.C24.grid(row = 27, column = 0, padx = 5, pady = 5)
        self.t24=Text(self.frame_content4,height=1,width = 20)
        self.t24.grid(row = 27, column = 1, padx = 5, pady = 5)
        l24=Label(self.frame_content4, text = ':  write all sent and received frames into pcap file',font=self.myfont, bg="white", justify=LEFT).grid(row = 27, column = 2, padx = 5, pady = 5)
        
        self.C25 = Checkbutton(self.frame_content4, text = "-P", \
                 onvalue = "-P", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var25)
        self.C25.grid(row = 28, column = 0, padx = 5, pady = 5)
        self.t25=Text(self.frame_content4,height=1,width = 20)
        self.t25.grid(row = 28, column = 1, padx = 5, pady = 5)
        l25=Label(self.frame_content4, text = ':  respond to all probes, even when specifying ESSIDs',font=self.myfont, bg="white", justify=LEFT).grid(row = 28, column = 2, padx = 5, pady = 5)
        
        
        self.C26 = Checkbutton(self.frame_content4, text = "-I", \
                 onvalue = "-I", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var26)
        self.C26.grid(row = 29, column = 0, padx = 5, pady = 5)
        self.t26=Text(self.frame_content4,height=1,width = 20)
        self.t26.grid(row = 29, column = 1, padx = 5, pady = 5)
        l26=Label(self.frame_content4, text = ':  sets the beacon interval value in ms',font=self.myfont, bg="white", justify=LEFT).grid(row = 29, column = 2, padx = 5, pady = 5)
        
        self.C27 = Checkbutton(self.frame_content4, text = "-C", \
                 onvalue = "-C", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var27)
        self.C27.grid(row = 30, column = 0, padx = 5, pady = 5)
        self.t27=Text(self.frame_content4,height=1,width = 20)
        self.t27.grid(row = 30, column = 1, padx = 5, pady = 5)
        l27=Label(self.frame_content4, text = ':   enables beaconing of probed ESSID values (requires -P)',font=self.myfont, bg="white", justify=LEFT).grid(row = 30, column = 2, padx = 5, pady = 5)
        
        Label(self.frame_content6, text = 'Airbase-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content6, text = 'Filter Options :',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 16, column = 1)
        
        self.C28 = Checkbutton(self.frame_content6, text = "--bssid", \
                 onvalue = "--bssid", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var28)
        self.C28.grid(row = 31, column = 0, padx = 5, pady = 5)
        self.t28=Text(self.frame_content6,height=1,width = 20)
        self.t28.grid(row = 31, column = 1, padx = 5, pady = 5)
        l28=Label(self.frame_content6, text = ':  BSSID to filter/use (short -b)',font=self.myfont, bg="white", justify=LEFT).grid(row = 31, column = 2, padx = 5, pady = 5)
        
        self.C29 = Checkbutton(self.frame_content6, text = "--bssids", \
                 onvalue = "--bssids", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var29)
        self.C29.grid(row = 32, column = 0, padx = 5, pady = 5)
        self.t29=Text(self.frame_content6,height=1,width = 20)
        self.t29.grid(row = 32, column = 1, padx = 5, pady = 5)
        l29=Label(self.frame_content6, text = ':  read a list of BSSIDs out of that file (short -B)',font=self.myfont, bg="white", justify=LEFT).grid(row = 32, column = 2, padx = 5, pady = 5)
        
        self.C30 = Checkbutton(self.frame_content6, text = "--client", \
                 onvalue = "--client", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var30)
        self.C30.grid(row = 33, column = 0, padx = 5, pady = 5)
        self.t30=Text(self.frame_content6,height=1,width = 20)
        self.t30.grid(row = 33, column = 1, padx = 5, pady = 5)
        l30=Label(self.frame_content6, text = ':   MAC of client to accept (short -d)',font=self.myfont, bg="white", justify=LEFT).grid(row = 33, column = 2, padx = 5, pady = 5)
        
        self.C31 = Checkbutton(self.frame_content6, text = "--clients", \
                 onvalue = "--clients", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var31)
        self.C31.grid(row = 34, column = 0, padx = 5, pady = 5)
        self.t31=Text(self.frame_content6,height=1,width = 20)
        self.t31.grid(row = 34, column = 1, padx = 5, pady = 5)
        l31=Label(self.frame_content6, text = ':  read a list of MACs out of that file (short -D)',font=self.myfont, bg="white", justify=LEFT).grid(row = 34, column = 2, padx = 5, pady = 5)
        
        self.C32 = Checkbutton(self.frame_content6, text = "--essid", \
                 onvalue = "--essid", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var32)
        self.C32.grid(row = 35, column = 0, padx = 5, pady = 5)
        self.t32=Text(self.frame_content6,height=1,width = 20)
        self.t32.grid(row = 35, column = 1, padx = 5, pady = 5)
        l32=Label(self.frame_content6, text = ':  specify a single ESSID (short -e)',font=self.myfont, bg="white", justify=LEFT).grid(row = 35, column = 2, padx = 5, pady = 5)
        
        self.C33 = Checkbutton(self.frame_content6, text = "--essids", \
                 onvalue = "--essids", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var33)
        self.C33.grid(row = 36, column = 0, padx = 5, pady = 5)
        self.t33=Text(self.frame_content6,height=1,width = 20)
        self.t33.grid(row = 36, column = 1, padx = 5, pady = 5)
        l33=Label(self.frame_content6, text = ':  read a list of ESSIDs out of that file (short -E)',font=self.myfont, bg="white", justify=LEFT).grid(row = 36, column = 2, padx = 5, pady = 5)
        
        self.C34 = Checkbutton(self.frame_content6, text = "--help", \
                 onvalue = "--help", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var34)
        self.C34.grid(row = 37, column = 0, padx = 5, pady = 5)
        self.t34=Text(self.frame_content6,height=1,width = 20)
        self.t34.grid(row = 37, column = 1, padx = 5, pady = 5)
        l34=Label(self.frame_content6, text = ':  Displays the usage screen (short -H)',font=self.myfont, bg="white", justify=LEFT).grid(row = 37, column = 2, padx = 5, pady = 5)
예제 #29
0
class GUI:

    ## GUI variables
    titleText = 'PyCX Simulator'  # window title
    timeInterval = 0              # refresh time in milliseconds
    running = False
    modelFigure = None
    stepSize = 1
    currentStep = 0
    def __init__(self,title='PyCX Simulator',interval=0,stepSize=1,parameterSetters=[]):
        self.titleText = title
        self.timeInterval = interval
        self.stepSize = stepSize
        self.parameterSetters = parameterSetters
        self.varEntries = {}
        self.statusStr = ""
               
        self.initGUI()
    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr) 
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW',self.quitGUI)
        self.rootWindow.geometry('550x400')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)
        
        self.notebook = Notebook(self.rootWindow)      
        self.notebook.grid(row=0,column=0,padx=2,pady=2,sticky='nswe')
        

        self.frameRun = Frame()
        self.frameSettings = Frame()
        self.frameParameters = Frame()
        self.frameInformation = Frame()          
        
        self.notebook.add(self.frameRun,text="Run")
        self.notebook.add(self.frameSettings,text="Settings")
        self.notebook.add(self.frameParameters,text="Parameters")
        self.notebook.add(self.frameInformation,text="Info")
     
        self.notebook.pack(expand=YES, fill=BOTH, padx=5, pady=5 ,side=TOP)
        self.status = Label(self.rootWindow, width=40,height=3, relief=SUNKEN, bd=1,textvariable=self.statusText)
        self.status.grid(row=1,column=0,padx=2,pady=2,sticky='nswe')
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)



        
        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameRun,width=30,height=2,textvariable=self.runPauseString,command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)



        self.showHelp(self.buttonRun,"Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameRun,width=30,height=2,text='Step Once',command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep,"Steps the simulation only once")
        self.buttonReset = Button(self.frameRun,width=30,height=2,text='Reset',command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5) 
        self.showHelp(self.buttonReset,"Resets the simulation")
 
   
        
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step size ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can,from_=1, to=50, resolution=1,command=self.changeStepSize,orient=HORIZONTAL, width=25,length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(self.stepScale,"Skips model redraw during every [n] simulation steps\nResults in a faster model run.")
        self.stepScale.pack(side='left')    
        can.pack(side='top')
    
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step visualization delay in ms ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepDelay = Scale(can,from_=0, to=max(2000,self.timeInterval), resolution=10,command=self.changeStepDelay,orient=HORIZONTAL, width=25,length=150)
        self.stepDelay.set(self.timeInterval)
        self.showHelp(self.stepDelay,"The visualization of each step is delays by the given number of milliseconds.")
        self.stepDelay.pack(side='left')    
        can.pack(side='top')
        scrollInfo = Scrollbar(self.frameInformation)
        self.textInformation = Text(self.frameInformation, width=45,height=13,bg='lightgray',wrap=WORD,font=("Courier",10))
        scrollInfo.pack(side=RIGHT, fill=Y)
        self.textInformation.pack(side=LEFT,fill=BOTH,expand=YES)
        scrollInfo.config(command=self.textInformation.yview)
        self.textInformation.config(yscrollcommand=scrollInfo.set)
        for variableSetter in self.parameterSetters:
            can = Canvas(self.frameParameters)
            lab = Label(can, width=25,height=1,text=variableSetter.__name__+" ",anchor=W,takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            ent.insert(0, str(variableSetter()))
            if variableSetter.__doc__ != None and len(variableSetter.__doc__) > 0:
                self.showHelp(ent,variableSetter.__doc__.strip())
            ent.pack(side='left')            
            can.pack(side='top')
            self.varEntries[variableSetter]=ent
        if len(self.parameterSetters) > 0:
            self.buttonSaveParameters = Button(self.frameParameters,width=50,height=1,command=self.saveParametersCmd,text="Save parameters to the running model",state=DISABLED)
            self.showHelp(self.buttonSaveParameters,"Saves the parameter values.\nNot all values may take effect on a running model\nA model reset might be required.")
            self.buttonSaveParameters.pack(side='top',padx=5,pady=5)
            self.buttonSaveParametersAndReset = Button(self.frameParameters,width=50,height=1,command=self.saveParametersAndResetCmd,text="Save parameters to the model and reset the model")
            self.showHelp(self.buttonSaveParametersAndReset,"Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top',padx=5,pady=5)
        
    
    def setStatusStr(self,newStatus):
        self.statusStr = newStatus
        self.statusText.set(self.statusStr)  
    #model control functions
    def changeStepSize(self,val):        
        self.stepSize = int(val)
    def changeStepDelay(self,val):        
        self.timeInterval= int(val)    
    def saveParametersCmd(self):
        for variableSetter in self.parameterSetters:
            variableSetter(float(self.varEntries[variableSetter].get()))
        self.setStatusStr("New parameter values have been set")
    def saveParametersAndResetCmd(self):
        self.saveParametersCmd()
        self.resetModel()

    def runEvent(self):
        self.running = not self.running
        if self.running:
            self.rootWindow.after(self.timeInterval,self.stepModel)
            self.runPauseString.set("Pause")
            self.buttonStep.configure(state=DISABLED)
            self.buttonReset.configure(state=DISABLED)
            if len(self.parameterSetters) > 0:
                self.buttonSaveParameters.configure(state=NORMAL)
                self.buttonSaveParametersAndReset.configure(state=DISABLED)     
        else:
            self.runPauseString.set("Continue Run")
            self.buttonStep.configure(state=NORMAL)
            self.buttonReset.configure(state=NORMAL)
            if len(self.parameterSetters) > 0:
                self.buttonSaveParameters.configure(state=NORMAL)
                self.buttonSaveParametersAndReset.configure(state=NORMAL)

    def stepModel(self):
        if self.running:
            self.modelStepFunc()
            self.currentStep += 1
            self.setStatusStr("Step "+str(self.currentStep))
            self.status.configure(foreground='black')
            if (self.currentStep) % self.stepSize == 0:
                self.drawModel()
            self.rootWindow.after(int(self.timeInterval*1.0/self.stepSize),self.stepModel)

    def stepOnce(self):
        self.running = False
        self.runPauseString.set("Continue Run")
        self.modelStepFunc()
        self.currentStep += 1
        self.setStatusStr("Step "+str(self.currentStep))
        self.drawModel()
        if len(self.parameterSetters) > 0:
            self.buttonSaveParameters.configure(state=NORMAL)

    def resetModel(self):
        self.running = False        
        self.runPauseString.set("Run")
        self.modelInitFunc()
        self.currentStep = 0;
        self.setStatusStr("Model has been reset")
        self.drawModel()

    def drawModel(self):
        
        if self.modelFigure == None or self.modelFigure.canvas.manager.window == None:
            self.modelFigure = PL.figure()
            PL.ion()
            PL.show()
        self.modelDrawFunc()
        self.modelFigure.canvas.manager.window.update()

    def start(self,func=[]):
        if len(func)==3:
            self.modelInitFunc = func[0]
            self.modelDrawFunc = func[1]
            self.modelStepFunc = func[2]            
            if (self.modelStepFunc.__doc__ != None and len(self.modelStepFunc.__doc__)>0):
                self.showHelp(self.buttonStep,self.modelStepFunc.__doc__.strip())                
            if (self.modelInitFunc.__doc__ != None and len(self.modelInitFunc.__doc__)>0):
                self.textInformation.config(state=NORMAL)
                self.textInformation.delete(1.0, END)
                self.textInformation.insert(END, self.modelInitFunc.__doc__.strip())
                self.textInformation.config(state=DISABLED)
                
            self.modelInitFunc()
            self.drawModel()     
        self.rootWindow.mainloop()

    def quitGUI(self):
        PL.close('all')
        self.rootWindow.quit()
        self.rootWindow.destroy()
    
    
    
    def showHelp(self, widget,text):
        def setText(self):
            self.statusText.set(text)
            self.status.configure(foreground='blue')
            
        def showHelpLeave(self):
            self.statusText.set(self.statusStr)
            self.status.configure(foreground='black')
        widget.bind("<Enter>", lambda e : setText(self))
        widget.bind("<Leave>", lambda e : showHelpLeave(self))
예제 #30
0
    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr) 
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW',self.quitGUI)
        self.rootWindow.geometry('550x400')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)
        
        self.notebook = Notebook(self.rootWindow)      
        self.notebook.grid(row=0,column=0,padx=2,pady=2,sticky='nswe')
        

        self.frameRun = Frame()
        self.frameSettings = Frame()
        self.frameParameters = Frame()
        self.frameInformation = Frame()          
        
        self.notebook.add(self.frameRun,text="Run")
        self.notebook.add(self.frameSettings,text="Settings")
        self.notebook.add(self.frameParameters,text="Parameters")
        self.notebook.add(self.frameInformation,text="Info")
     
        self.notebook.pack(expand=YES, fill=BOTH, padx=5, pady=5 ,side=TOP)
        self.status = Label(self.rootWindow, width=40,height=3, relief=SUNKEN, bd=1,textvariable=self.statusText)
        self.status.grid(row=1,column=0,padx=2,pady=2,sticky='nswe')
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)



        
        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameRun,width=30,height=2,textvariable=self.runPauseString,command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)



        self.showHelp(self.buttonRun,"Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameRun,width=30,height=2,text='Step Once',command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep,"Steps the simulation only once")
        self.buttonReset = Button(self.frameRun,width=30,height=2,text='Reset',command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5) 
        self.showHelp(self.buttonReset,"Resets the simulation")
 
   
        
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step size ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can,from_=1, to=50, resolution=1,command=self.changeStepSize,orient=HORIZONTAL, width=25,length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(self.stepScale,"Skips model redraw during every [n] simulation steps\nResults in a faster model run.")
        self.stepScale.pack(side='left')    
        can.pack(side='top')
    
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step visualization delay in ms ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepDelay = Scale(can,from_=0, to=max(2000,self.timeInterval), resolution=10,command=self.changeStepDelay,orient=HORIZONTAL, width=25,length=150)
        self.stepDelay.set(self.timeInterval)
        self.showHelp(self.stepDelay,"The visualization of each step is delays by the given number of milliseconds.")
        self.stepDelay.pack(side='left')    
        can.pack(side='top')
        scrollInfo = Scrollbar(self.frameInformation)
        self.textInformation = Text(self.frameInformation, width=45,height=13,bg='lightgray',wrap=WORD,font=("Courier",10))
        scrollInfo.pack(side=RIGHT, fill=Y)
        self.textInformation.pack(side=LEFT,fill=BOTH,expand=YES)
        scrollInfo.config(command=self.textInformation.yview)
        self.textInformation.config(yscrollcommand=scrollInfo.set)
        for variableSetter in self.parameterSetters:
            can = Canvas(self.frameParameters)
            lab = Label(can, width=25,height=1,text=variableSetter.__name__+" ",anchor=W,takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            ent.insert(0, str(variableSetter()))
            if variableSetter.__doc__ != None and len(variableSetter.__doc__) > 0:
                self.showHelp(ent,variableSetter.__doc__.strip())
            ent.pack(side='left')            
            can.pack(side='top')
            self.varEntries[variableSetter]=ent
        if len(self.parameterSetters) > 0:
            self.buttonSaveParameters = Button(self.frameParameters,width=50,height=1,command=self.saveParametersCmd,text="Save parameters to the running model",state=DISABLED)
            self.showHelp(self.buttonSaveParameters,"Saves the parameter values.\nNot all values may take effect on a running model\nA model reset might be required.")
            self.buttonSaveParameters.pack(side='top',padx=5,pady=5)
            self.buttonSaveParametersAndReset = Button(self.frameParameters,width=50,height=1,command=self.saveParametersAndResetCmd,text="Save parameters to the model and reset the model")
            self.showHelp(self.buttonSaveParametersAndReset,"Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top',padx=5,pady=5)
예제 #31
0
    def initUI(self, students):

        note=Notebook(self.parent)



        #Tabs
        external_tab = Frame(note)
        records_tab = Frame(note)
        edit_tab = Frame(note)
        note.config()
        note.add(external_tab, text = "Attendance")
        note.add(records_tab, text="  Records  ")
        note.add(edit_tab, text="    Edit    ")


        #Create the scrollable list on the left side
        scrollbar = tk.Scrollbar(external_tab, orient="vertical")
        lb = tk.Listbox(external_tab, selectmode=MULTIPLE, width=30, height=20, yscrollcommand=scrollbar.set)
        scrollbar.config(command=lb.yview)
        scrollbar.pack(side="left", fill="y")
        lb.pack(side="left",fill="y")
        self.setList(students, lb)



        #Add dialogue box for new student
        frame1 = Frame(external_tab, relief=GROOVE, borderwidth=0)
        info_frame2 = Frame(records_tab, relief=GROOVE, borderwidth=3)
        name = tk.Entry(frame1)
        name.pack(anchor=CENTER, side=BOTTOM)
        frame1.pack(fill=BOTH, expand=1)
        self.pack(fill=BOTH, expand=1)

        #Add the buttons on the right to manipulate the list
        frame = Frame(external_tab, relief=RAISED, borderwidth=0)
        addButton = Button(frame, text="Add Student", command= lambda : self.addStudent(name.get(), lb, lb2, lb3))
        addButton.pack()
        deleteButton = Button(frame, text="Remove Student", command= lambda : self.deleteStudent(lb.curselection(), lb, lb2, lb3))
        deleteButton.pack(anchor=E, pady=20, side=RIGHT)
        frame.pack()

        markCalendarFrame = Frame(external_tab)
        self.markCalendar = Calendar.newCalendar(markCalendarFrame, True)
        markCalendarFrame.pack()

        #Add the reset button and the mark absent button
        frame2 = Frame(external_tab, relief=RAISED, borderwidth=0)
        absentButton = Button(frame2, text="Mark as Absent", command= lambda: self.markAbsent(lb.curselection()))
        absentButton.pack(side=TOP, pady=20)
        resetButton = Button(frame2, text="Reset Today's Attendance", command=self.resetDay)
        resetButton.pack(side=TOP, pady=20)
        frame2.pack(fill=BOTH, expand=1)
        self.pack(fill=BOTH, expand=1)

        #Create the Records Listbox
        scrollbar2 = tk.Scrollbar(records_tab, orient="vertical")
        lb2 = tk.Listbox(records_tab, selectmode=BROWSE, width=30, height=20, yscrollcommand=scrollbar2.set)
        scrollbar2.config(command=lb2.yview)
        scrollbar2.pack(side="left", fill="y")

        #Bind a click to finding attendance
        lb2.bind('<<ListboxSelect>>', self.getTotals)
        lb2.pack(side="left",fill="y")
        self.setList(students, lb2)

        #Create the text that updates in real time based on selection

        self.present_variable.set('')
        self.absent_variable.set('')
        info_frame = Frame(records_tab, relief=GROOVE, borderwidth=3)
        present_setup = tk.Message(records_tab, anchor=W, justify=CENTER, width=100, text="Days Present: ")
        present_setup.pack(fill=X, side=TOP)
        present_message = tk.Message(records_tab, anchor=E, justify=CENTER, width=100, textvariable= self.present_variable)
        present_message.pack(fill=X, side=TOP)
        info_frame.pack(side=TOP)




        absent_setup = tk.Message(records_tab, anchor=W, justify=CENTER, width=100, text="Days Absent: ")
        absent_setup.pack(fill=X, side=TOP)
        absent_variable = tk.Message(records_tab, anchor=E, justify=CENTER, width=100, textvariable= self.absent_variable)
        absent_variable.pack(fill=X, side=TOP)
        info_frame2.pack(side=TOP)



        #Create a see Calendar Button
        # calendarButton = Button(records_tab, text="See Specific Days", command= lambda : self.setStudentCalendar(lb2.curselection()))
        # calendarButton.pack(side=TOP)


        calendar_frame = Frame(records_tab, relief=GROOVE, borderwidth=3, width = 300)
        self.theCalendar = Calendar.newCalendar(calendar_frame, False)
        calendar_frame.pack(side=TOP, pady = 20)

        clearCalendarButton = Button(records_tab, text="Clear Calendar", command=self.clearStudentCalendar)
        clearCalendarButton.pack(side=TOP)

        # close and excel buttons
        bottomFrame = Frame(width=20)
        excelButton = Button(bottomFrame, text="Generate Excel", command=self.generateExcel)
        excelButton.pack(side=LEFT, padx=5, pady=5)

        closeButton = Button(bottomFrame, text="Close", command=self.closeButton)
        closeButton.pack(side=RIGHT, padx=10, pady=5)
        bottomFrame.pack(side=BOTTOM)


        scrollbar3 = tk.Scrollbar(edit_tab, orient="vertical")
        lb3 = tk.Listbox(edit_tab, selectmode=BROWSE, width=30, height=20, yscrollcommand=scrollbar3.set)
        scrollbar3.config(command=lb3.yview)
        scrollbar3.pack(side="left", fill="y")
        lb3.bind('<<ListboxSelect>>', self.get_dates)
        lb3.pack(side="left",fill="y")
        self.setList(students, lb3)

        addFrame = Frame(edit_tab)
        remove_date = Button(addFrame, text="Remove Date", command= lambda : self.remove_date(self.lbedit.curselection(), self.lbedit2.curselection(), True))
        remove_date.pack(side=TOP, pady=2)
        add_dates = Button(addFrame, text="Add Date", command= lambda : self.add_date(lb3.curselection()))
        add_dates.pack(side=LEFT, pady=2)
        edit_selection = Button(addFrame, text="Edit Date", command= lambda : self.edit_date(self.lbedit.curselection(), self.lbedit2.curselection()))
        edit_selection.pack(side=LEFT, pady=2)

        addFrame.pack(side=TOP)

        dateFrame = Frame(edit_tab)
        presentLabel = Label(dateFrame, text="Present")
        presentLabel.pack(side=TOP)
        scrollbar4 = tk.Scrollbar(dateFrame, orient="vertical")
        self.lbedit = tk.Listbox(dateFrame, selectmode=BROWSE, width=29, height=9, yscrollcommand=scrollbar4.set)
        self.lbedit.pack(side=TOP)

        absentLabel = Label(dateFrame, text="Absent")
        absentLabel.pack(side=TOP)
        scrollbar5 = tk.Scrollbar(dateFrame, orient="vertical")
        self.lbedit2 = tk.Listbox(dateFrame, selectmode=BROWSE, width=29, height=8, yscrollcommand=scrollbar5.set)
        self.lbedit2.pack(side=TOP, fill="y")

        dateFrame.pack(side=LEFT, fill="y")

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

        note.pack(fill=BOTH, expand=1)
예제 #32
0
    def __init__(self, master):

        self.fname = ""
        #global variables
        self.t1 = StringVar()
        self.t2 = StringVar()
        self.t3 = StringVar()
        self.t4 = StringVar()
        self.t5 = StringVar()
        self.t6 = StringVar()
        self.t7 = StringVar()
        self.t8 = StringVar()

        self.var1 = StringVar()
        self.var2 = StringVar()
        self.var3 = StringVar()
        self.var4 = StringVar()
        self.var5 = StringVar()
        self.var6 = StringVar()
        self.var7 = StringVar()
        self.var8 = StringVar()
        #end

        mymaster = Frame(master, name='mymaster')  # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window
        #master.minsize(width=900, height=900)
        #master.maxsize(width=870, height=420)
        #end

        #title of window
        master.title("Airolib-ng")
        #end

        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont = tkFont.Font(family="Helvetica",
                                      size=15,
                                      underline=True)
        self.myfontnew = tkFont.Font(family="Helvetica",
                                     size=11,
                                     underline=True)
        #end

        nb = Notebook(mymaster, name='nb')  # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3)  # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,
                                   name="frame_content",
                                   bg="lightsteelblue")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1")  # add tab to Notebook

        # repeat for each tab
        self.frame_content7 = Frame(nb,
                                    name='frame_content7',
                                    bg="lightsteelblue")
        nb.add(self.frame_content7, text="Detect Devices")
        self.frame_content5 = Frame(nb,
                                    name='frame_content5',
                                    bg="lightsteelblue")
        nb.add(self.frame_content5, text="output")

        #End

        #frame content 7
        Label(self.frame_content7,
              text='Airolib-ng',
              font=self.headerfont,
              bg="midnightblue",
              fg="firebrick",
              padx=10,
              pady=10).grid(row=0, column=0)
        btndetect = Button(self.frame_content7,
                           text='Detect',
                           fg="cornflowerblue",
                           command=self.canvas_detect,
                           height=2,
                           width=15,
                           font=self.customFont).grid(row=1,
                                                      column=0,
                                                      padx=5,
                                                      pady=5)

        btndbrowse = Button(self.frame_content7,
                            text='Attach File',
                            fg="cornflowerblue",
                            command=self.browse_file,
                            height=2,
                            width=15,
                            font=self.customFont).grid(row=3,
                                                       column=0,
                                                       padx=5,
                                                       pady=5)
        self.lilnew1 = Listbox(self.frame_content7,
                               bg="black",
                               fg="firebrick",
                               font=self.myfont,
                               selectmode=SINGLE,
                               width=30,
                               height=15)
        self.lilnew1.grid(row=1, column=1, rowspan=3)
        #End

        Label(self.frame_content,
              text='Airolib-ng',
              font=self.headerfont,
              bg="midnightblue",
              fg="firebrick",
              padx=10,
              pady=10).grid(row=0, column=0)
        Label(self.frame_content,
              text='Options :',
              font=self.myfontnew,
              bg="midnightblue",
              fg="deepskyblue").grid(row=1, column=1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5,
              text='Edit Command From Here',
              font=self.myfontnew,
              bg="midnightblue",
              fg="deepskyblue",
              justify=LEFT).grid(row=0, column=0)
        TextCommandBox = Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output = Text(self.frame_content5,
                           bg="black",
                           fg="firebrick",
                           font=self.myfont,
                           height=20,
                           width=42)
        self.output.grid(row=0, column=1, padx=50, pady=5, rowspan=3)
        btnsubmit = Button(self.frame_content5,
                           width=15,
                           height=2,
                           text="Get Result",
                           fg="cornflowerblue",
                           command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear = Button(self.frame_content5,
                          width=15,
                          height=2,
                          text="Clear Output",
                          fg="cornflowerblue",
                          command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "--stats", fg="deepskyblue", \
                 onvalue = "--stats", offvalue = "", height=1, \
                 width = 7, bg="midnightblue", font=self.customFont,variable=self.var1)
        self.C1.grid(row=2, column=0, padx=5, pady=5)
        self.t1 = Text(self.frame_content, height=1, width=20)
        self.t1.grid(row=2, column=1, padx=5, pady=5)
        l1 = Label(self.frame_content,
                   text=': Output some information about the database.',
                   font=self.myfont,
                   bg="midnightblue",
                   fg="deepskyblue",
                   justify=LEFT).grid(row=2, column=2, padx=5, pady=5)

        self.C2 = Checkbutton(self.frame_content, text = "--sql", fg="deepskyblue", \
                 onvalue = "--sql", offvalue = "", height=1, \
                 width = 7, bg="midnightblue", font=self.customFont,variable=self.var2)
        self.C2.grid(row=3, column=0, padx=5, pady=5)
        self.t2 = Text(self.frame_content, height=1, width=20)
        self.t2.grid(row=3, column=1, padx=5, pady=5)
        l2 = Label(self.frame_content,
                   text=': Execute the specified SQL statement.',
                   font=self.myfont,
                   bg="midnightblue",
                   fg="deepskyblue",
                   justify=LEFT).grid(row=3, column=2, padx=5, pady=5)

        self.C3 = Checkbutton(self.frame_content, text = "--clean", fg="deepskyblue", \
                 onvalue = "--clean", offvalue = "", height=1, \
                 width = 7, bg="midnightblue", font=self.customFont,variable=self.var3)
        self.C3.grid(row=4, column=0, padx=5, pady=5)
        self.t3 = Text(self.frame_content, height=1, width=20)
        self.t3.grid(row=4, column=1, padx=5, pady=5)
        l3 = Label(
            self.frame_content,
            text=':   Perform steps to clean the database from old junk.',
            font=self.myfont,
            bg="midnightblue",
            fg="deepskyblue",
            justify=LEFT).grid(row=4, column=2, padx=5, pady=5)

        self.C4 = Checkbutton(self.frame_content, text = "- -batch", fg="deepskyblue", \
                 onvalue = "--verify", offvalue = "", height=1, \
                 width = 7, bg="midnightblue", font=self.customFont,variable=self.var4)
        self.C4.grid(row=5, column=0, padx=5, pady=5)
        self.t4 = Text(self.frame_content, height=1, width=20)
        self.t4.grid(row=5, column=1, padx=5, pady=5)
        l4 = Label(
            self.frame_content,
            text=
            ': Start batch-processing all combinations of ESSIDs and passwords.',
            font=self.myfont,
            bg="midnightblue",
            fg="deepskyblue",
            justify=LEFT).grid(row=5, column=2, padx=5, pady=5)

        self.C5 = Checkbutton(self.frame_content, text = "--verify", fg="deepskyblue", \
                 onvalue = "--verify", offvalue = "", height=1, \
                 bg="midnightblue", font=self.customFont,variable=self.var5)
        self.C5.grid(row=6, column=0, padx=5, pady=5)
        self.t5 = Text(self.frame_content, height=1, width=20)
        self.t5.grid(row=6, column=1, padx=5, pady=5)
        l5 = Label(self.frame_content,
                   text=':  Verify a set of randomly chosen PMKs.',
                   font=self.myfont,
                   bg="midnightblue",
                   fg="deepskyblue",
                   justify=LEFT).grid(row=6, column=2, padx=5, pady=5)

        self.C6 = Checkbutton(self.frame_content, text = "--export", fg="deepskyblue", \
                 onvalue = "--export", offvalue = "", height=1, \
                 bg="midnightblue", font=self.customFont,variable=self.var6)
        self.C6.grid(row=7, column=0, padx=5, pady=5)
        self.t6 = Text(self.frame_content, height=1, width=20)
        self.t6.grid(row=7, column=1, padx=5, pady=5)
        l6 = Label(self.frame_content,
                   text=':  Export to a cowpatty file.',
                   font=self.myfont,
                   bg="midnightblue",
                   fg="deepskyblue",
                   justify=LEFT).grid(row=7, column=2, padx=5, pady=5)

        self.C7 = Checkbutton(self.frame_content, text = "--import cowpatty", fg="deepskyblue", \
                 onvalue = "--import cowpatty", offvalue = "", height=1, \
                 bg="midnightblue", font=self.customFont,variable=self.var7)
        self.C7.grid(row=8, column=0, padx=5, pady=5)
        self.t7 = Text(self.frame_content, height=1, width=20)
        self.t7.grid(row=8, column=1, padx=5, pady=5)
        l7 = Label(self.frame_content,
                   text=':  Import a cowpatty file and create the database.',
                   font=self.myfont,
                   bg="midnightblue",
                   fg="deepskyblue",
                   justify=LEFT).grid(row=8, column=2, padx=5, pady=5)

        self.C8 = Checkbutton(self.frame_content, text = "--import", fg="deepskyblue", \
                 onvalue = "--import", offvalue = "", height=1, \
                 bg="midnightblue", font=self.customFont,variable=self.var8)
        self.C8.grid(row=9, column=0, padx=5, pady=5)
        self.t8 = Text(self.frame_content, height=1, width=20)
        self.t8.grid(row=9, column=1, padx=5, pady=5)
        l8 = Label(
            self.frame_content,
            text=
            ':  Import a text flat file as a list of either ESSIDs or passwords and create the database.',
            font=self.myfont,
            bg="midnightblue",
            fg="deepskyblue",
            justify=LEFT).grid(row=9, column=2, padx=5, pady=5)
예제 #33
0
파일: gui.py 프로젝트: ravescovi/tomosaic2
    def initUI(self):

        self.parent.title('Tomosaic')

        # ======================================================
        # menubar

        menuFrame = Frame(self.parent)
        menubar = Menu(menuFrame)
        self.parent.config(menu=menubar)

        fileFenu = Menu(menubar)
        fileFenu.add_command(label='Save parameters...',
                             command=self.saveAllAttr)
        fileFenu.add_command(label='Load parameters...',
                             command=self.loadAllAttr)
        fileFenu.add_command(label='Exit', command=self.onExit)
        menubar.add_cascade(label='File', menu=fileFenu)

        # ======================================================d
        # tabs

        tabFrame = Frame(root)
        tabs = Notebook(tabFrame)
        self.tabMeta = Frame(tabs)
        self.tabRegi = Frame(tabs)
        self.tabMerg = Frame(tabs)
        self.tabPhas = Frame(tabs)
        self.tabCent = Frame(tabs)
        self.tabReco = Frame(tabs)

        tabs.add(self.tabMeta, text='Metadata')
        tabs.add(self.tabRegi, text='Registration')
        tabs.add(self.tabMerg, text='Merging')
        tabs.add(self.tabPhas, text='Phase')
        tabs.add(self.tabCent, text='Center optimization')
        tabs.add(self.tabReco, text='Reconstruction')

        metatab_ui(self)
        regitab_ui(self)
        mergtab_ui(self)
        phastab_ui(self)
        centtab_ui(self)
        recotab_ui(self)

        tabFrame.pack()
        tabs.pack()
예제 #34
0
파일: notevi.py 프로젝트: yutzhead/vy
    def __init__(self, *args, **kwargs):
        """

        """

        Notebook.__init__(self, *args, **kwargs)
예제 #35
0
    def __init__(self, master):
        
	self.fname=""
        #global variables
        self.t1=StringVar()
        self.t2=StringVar()
        self.t3=StringVar()
        self.t4=StringVar()
        self.t5=StringVar()
        self.t6=StringVar()
        self.t7=StringVar()
        self.t8=StringVar()
        self.t9=StringVar()
        self.t10=StringVar()
        self.t11=StringVar()
        self.t12=StringVar()
        self.t13=StringVar()
        self.t14=StringVar()
        self.t15=StringVar()
        self.t16=StringVar()
        self.t17=StringVar()
        self.t18=StringVar()
        self.t19=StringVar()
        self.t20=StringVar()
        self.t21=StringVar()
        self.t22=StringVar()
        self.t23=StringVar()
        self.t24=StringVar()
        self.t25=StringVar()
        self.t26=StringVar()
        
        self.var1=StringVar()
        self.var2=StringVar()
        self.var3=StringVar()
        self.var4=StringVar()
        self.var5=StringVar()
        self.var6=StringVar()
        self.var7=StringVar()
        self.var8=StringVar()
        self.var9=StringVar()
        self.var10=StringVar()
        self.var11=StringVar()
        self.var12=StringVar()
        self.var13=StringVar()
        self.var14=StringVar()
        self.var15=StringVar()
        self.var16=StringVar()
        self.var17=StringVar()
        self.var18=StringVar()
        self.var19=StringVar()
        self.var20=StringVar()
        self.var21=StringVar()
        self.var22=StringVar()
        self.var23=StringVar()
        self.var24=StringVar()
        self.var25=StringVar()
        self.var26=StringVar()
        #end
        
        mymaster = Frame(master, name='mymaster') # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window    
        #master.minsize(width=900, height=900)
        #master.maxsize(width=650, height=410)
        #end
        
        #title of window
        master.title("Airodump-ng")
        #end
        
        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont=tkFont.Font(family="Helvetica", size=15,underline = True)
        self.myfontnew=tkFont.Font(family="Helvetica", size=11,underline = True)
        #end
        
        
       
        nb = Notebook(mymaster, name='nb') # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3) # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1") # add tab to Notebook
    
        # repeat for each tab
        self.frame_content2 = Frame(nb, name='frame_content2', bg="white")
        nb.add(self.frame_content2, text="Filter-2")
        self.frame_content3 = Frame(nb, name='frame_content3', bg="white")
        nb.add(self.frame_content3, text="Filter-3")
        self.frame_content4 = Frame(nb, name='frame_content4', bg="white")
        nb.add(self.frame_content4, text="Filter-4")
	self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")        
	self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        #End
        
	#frame content 7
	Label(self.frame_content7, text = 'Airodump-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        btndetect=Button(self.frame_content7, text = 'Detect', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 1, column = 0, padx = 5, pady = 5)
		
	btndbrowse=Button(self.frame_content7, text = 'Attach File', command =self.browse_file, height=2, width=15, font=self.customFont).grid(row = 3, column = 0, padx = 5, pady = 5)	
	self.lilnew1=Listbox(self.frame_content7,bg="black", fg="white", font=self.myfont, selectmode=SINGLE, width=30, height=15)
        self.lilnew1.grid(row = 1, column = 1, rowspan=3)
	#End

        Label(self.frame_content, text = 'Airodump-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content, text = 'Options :',font=self.myfontnew, bg="white").grid(row = 1, column = 1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5, text = 'Edit Command From Here',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 0, column = 0)
        TextCommandBox=Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output=Text(self.frame_content5,bg="black", fg="white", font=self.myfont, height=20, width=42)
        self.output.grid(row = 0, column = 1, padx=50, pady=5, rowspan=3)
        btnsubmit=Button(self.frame_content5, width=15, height=2, text="Get Result", command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear=Button(self.frame_content5, width=15, height=2, text="Clear Output", command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "--ivs", \
                 onvalue = "--ivs", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var1)
        self.C1.grid(row = 2, column = 0, padx = 5, pady = 5)
        self.t1=Text(self.frame_content,height=1,width = 20)
        self.t1.grid(row = 2, column = 1, padx = 5, pady = 5)
        l1=Label(self.frame_content, text = ': Save only captured IVs',font=self.myfont, bg="white", justify=LEFT).grid(row = 2, column = 2, padx = 5, pady = 5)
        
        self.C2 = Checkbutton(self.frame_content, text = "--gpsd", \
                 onvalue = "--gpsd", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var2)
        self.C2.grid(row = 3, column = 0, padx = 5, pady = 5)
        self.t2=Text(self.frame_content,height=1,width = 20)
        self.t2.grid(row = 3, column = 1, padx = 5, pady = 5)
        l2=Label(self.frame_content, text = ': Use GPSd',font=self.myfont, bg="white", justify=LEFT).grid(row = 3, column = 2, padx = 5, pady = 5)
        
        self.C3 = Checkbutton(self.frame_content, text = "--write", \
                 onvalue = "--write", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row = 4, column = 0, padx = 5, pady = 5)
        self.t3=Text(self.frame_content,height=1,width = 20)
        self.t3.grid(row = 4, column = 1, padx = 5, pady = 5)
        l3=Label(self.frame_content, text = ': Dump file prefix',font=self.myfont, bg="white", justify=LEFT).grid(row = 4, column = 2, padx = 5, pady = 5)
        
        self.C4 = Checkbutton(self.frame_content, text = "-w", \
                 onvalue = "-w", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row = 5, column = 0, padx = 5, pady = 5)
        self.t4=Text(self.frame_content,height=1,width = 20)
        self.t4.grid(row = 5, column = 1, padx = 5, pady = 5)
        l4=Label(self.frame_content, text = ': same as --write',font=self.myfont, bg="white", justify=LEFT).grid(row = 5, column = 2, padx = 5, pady = 5)
        
        self.C5 = Checkbutton(self.frame_content, text = "--beacons", \
                 onvalue = "--beacon", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var5)
        self.C5.grid(row = 6, column = 0, padx = 5, pady = 5)
        self.t5=Text(self.frame_content,height=1,width = 20)
        self.t5.grid(row = 6, column = 1, padx = 5, pady = 5)
        l5=Label(self.frame_content, text = ': Record all beacons in dump file',font=self.myfont, bg="white", justify=LEFT).grid(row = 6, column = 2, padx = 5, pady = 5)
        
        self.C6 = Checkbutton(self.frame_content, text = "--update", \
                 onvalue = "--update", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var6)
        self.C6.grid(row = 7, column = 0, padx = 5, pady = 5)
        self.t6=Text(self.frame_content,height=1,width = 20)
        self.t6.grid(row = 7, column = 1, padx = 5, pady = 5)
        l6=Label(self.frame_content, text = ': Display update delay in seconds',font=self.myfont, bg="white", justify=LEFT).grid(row = 7, column = 2, padx = 5, pady = 5)
        
        self.C7 = Checkbutton(self.frame_content, text = "--showack", \
                 onvalue = "--showack", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var7)
        self.C7.grid(row = 8, column = 0, padx = 5, pady = 5)
        self.t7=Text(self.frame_content,height=1,width = 20)
        self.t7.grid(row = 8, column = 1, padx = 5, pady = 5)
        l7=Label(self.frame_content, text = ': Prints ack/cts/rts statistics',font=self.myfont, bg="white", justify=LEFT).grid(row = 8, column = 2, padx = 5, pady = 5)
        
        self.C8 = Checkbutton(self.frame_content2, text = "-h", \
                 onvalue = "-h", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var8)
        self.C8.grid(row = 9, column = 0, padx = 5, pady = 5)
        self.t8=Text(self.frame_content2,height=1,width = 20)
        self.t8.grid(row = 9, column = 1, padx = 5, pady = 5)
        l8=Label(self.frame_content2, text = ': Hides known stations for --showack',font=self.myfont, bg="white", justify=LEFT).grid(row = 9, column = 2, padx = 5, pady = 5)
        
        self.C9 = Checkbutton(self.frame_content2, text = "-f", \
                 onvalue = "-f", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var9)
        self.C9.grid(row = 10, column = 0, padx = 5, pady = 5)
        self.t9=Text(self.frame_content2,height=1,width = 20)
        self.t9.grid(row = 10, column = 1, padx = 5, pady = 5)
        l9=Label(self.frame_content2, text = ': Time in ms between hopping channels',font=self.myfont, bg="white", justify=LEFT).grid(row = 10, column = 2, padx = 5, pady = 5)
        
        Label(self.frame_content2, text = 'Airodump-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        
        self.C10 = Checkbutton(self.frame_content2, text = "--berlin", \
                 onvalue = "--berlin", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var10)
        self.C10.grid(row = 11, column = 0, padx = 5, pady = 5)
        self.t10=Text(self.frame_content2,height=1,width = 20)
        self.t10.grid(row = 11, column = 1, padx = 5, pady = 5)
        l10=Label(self.frame_content2, text = ': Time before removing the AP/client',font=self.myfont, bg="white", justify=LEFT).grid(row = 11, column = 2, padx = 5, pady = 5)
        
        self.C11 = Checkbutton(self.frame_content2, text = "-r", \
                 onvalue = "-r", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var11)
        self.C11.grid(row = 12, column = 0, padx = 5, pady = 5)
        self.t11=Text(self.frame_content2,height=1,width = 20)
        self.t11.grid(row = 12, column = 1, padx = 5, pady = 5)
        l11=Label(self.frame_content2, text = ': Read packets from that file',font=self.myfont, bg="white", justify=LEFT).grid(row = 12, column = 2, padx = 5, pady = 5)
        
        self.C12 = Checkbutton(self.frame_content2, text = "-x", \
                 onvalue = "-x", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var12)
        self.C12.grid(row = 13, column = 0, padx = 5, pady = 5)
        self.t12=Text(self.frame_content2,height=1,width = 20)
        self.t12.grid(row = 13, column = 1, padx = 5, pady = 5)
        l12=Label(self.frame_content2, text = ': Active Scanning Simulation',font=self.myfont, bg="white", justify=LEFT).grid(row = 13, column = 2, padx = 5, pady = 5)
        
        self.C13 = Checkbutton(self.frame_content2, text = " --output-format", \
                 onvalue = "--output-format", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var13)
        self.C13.grid(row = 14, column = 0, padx = 5, pady = 5)
        self.t13=Text(self.frame_content2,height=1,width = 20)
        self.t13.grid(row = 14, column = 1, padx = 5, pady = 5)
        l13=Label(self.frame_content2, text = ': Output format. Possible values',font=self.myfont, bg="white", justify=LEFT).grid(row = 14, column = 2, padx = 5, pady = 5)
        
        self.C14 = Checkbutton(self.frame_content2, text = " --ignore-negative-one", \
                 onvalue = "--ignore-negative-one", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var14)
        self.C14.grid(row = 15, column = 0, padx = 5, pady = 5)
        self.t14=Text(self.frame_content2,height=1,width = 20)
        self.t14.grid(row = 15, column = 1, padx = 5, pady = 5)
        l14=Label(self.frame_content2, text = ': Removes the message that says fixed channel',font=self.myfont, bg="white").grid(row = 15, column = 2, padx = 5, pady = 5)
        
        
        Label(self.frame_content3, text = 'Airodump-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content3, text = 'Filter Options :',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 16, column = 1)
        
        self.C15 = Checkbutton(self.frame_content3, text = "--encrypt", \
                 onvalue = "--encrypt", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var15)
        self.C15.grid(row = 17, column = 0, padx = 5, pady = 5)
        self.t15=Text(self.frame_content3,height=1,width = 20)
        self.t15.grid(row = 17, column = 1, padx = 5, pady = 5)
        l15=Label(self.frame_content3, text = ': Filter APs by cipher suite',font=self.myfont, bg="white", justify=LEFT).grid(row = 17, column = 2, padx = 5, pady = 5)
        
        self.C16 = Checkbutton(self.frame_content3, text = "--netmask", \
                 onvalue = "--netmask", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var16)
        self.C16.grid(row = 18, column = 0, padx = 5, pady = 5)
        self.t16=Text(self.frame_content3,height=1,width = 20)
        self.t16.grid(row = 18, column = 1, padx = 5, pady = 5)
        l16=Label(self.frame_content3, text = ': Filter APs by mask',font=self.myfont, bg="white", justify=LEFT).grid(row = 18, column = 2, padx = 5, pady = 5)
        
        self.C17 = Checkbutton(self.frame_content3, text = "--bssid", \
                 onvalue = "--bssid", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var17)
        self.C17.grid(row = 19, column = 0, padx = 5, pady = 5)
        self.t17=Text(self.frame_content3,height=1,width = 20)
        self.t17.grid(row = 19, column = 1, padx = 5, pady = 5)
        l17=Label(self.frame_content3, text = ': Filter APs by BSSID',font=self.myfont, bg="white", justify=LEFT).grid(row = 19, column = 2, padx = 5, pady = 5)
        
        self.C18 = Checkbutton(self.frame_content3, text = "--essid", \
                 onvalue = "--essid", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var18)
        self.C18.grid(row = 20, column = 0, padx = 5, pady = 5)
        self.t18=Text(self.frame_content3,height=1,width = 20)
        self.t18.grid(row = 20, column = 1, padx = 5, pady = 5)
        l18=Label(self.frame_content3, text = ': Filter APs by ESSID',font=self.myfont, bg="white", justify=LEFT).grid(row = 20, column = 2, padx = 5, pady = 5)
        
        self.C19 = Checkbutton(self.frame_content3, text = "--essid-regex", \
                 onvalue = "--essid-regex", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var19)
        self.C19.grid(row = 21, column = 0, padx = 5, pady = 5)
        self.t19=Text(self.frame_content3,height=1,width = 20)
        self.t19.grid(row = 21, column = 1, padx = 5, pady = 5)
        l19=Label(self.frame_content3, text = ': Filter APs by ESSID using \n  a regular expression',font=self.myfont, bg="white", justify=LEFT).grid(row = 21, column = 2, padx = 5, pady = 5)
        
        self.C20 = Checkbutton(self.frame_content3, text = "-a", \
                 onvalue = "-a", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var20)
        self.C20.grid(row = 22, column = 0, padx = 5, pady = 5)
        self.t20=Text(self.frame_content3,height=1,width = 20)
        self.t20.grid(row = 22, column = 1, padx = 5, pady = 5)
        l20=Label(self.frame_content3, text = ': Filter unassociated clients',font=self.myfont, bg="white", justify=LEFT).grid(row = 22, column = 2, padx = 5, pady = 5)
        
        Label(self.frame_content4, text = 'Airodump-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        
        self.C21 = Checkbutton(self.frame_content4, text = "--channel", \
                 onvalue = "--channel", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var21)
        self.C21.grid(row = 23, column = 0, padx = 5, pady = 5)
        self.t21=Text(self.frame_content4,height=1,width = 20)
        self.t21.grid(row = 23, column = 1, padx = 5, pady = 5)
        l21=Label(self.frame_content4, text = ': Capture on specific channels',font=self.myfont, bg="white", justify=LEFT).grid(row = 23, column = 2, padx = 5, pady = 5)
        
        self.C22 = Checkbutton(self.frame_content4, text = "--band", \
                 onvalue = "--band", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var22)
        self.C22.grid(row = 24, column = 0, padx = 5, pady = 5)
        self.t22=Text(self.frame_content4,height=1,width = 20)
        self.t22.grid(row = 24, column = 1, padx = 5, pady = 5)
        l22=Label(self.frame_content4, text = ':  Band on which airodump-ng should hop',font=self.myfont, bg="white", justify=LEFT).grid(row = 24, column = 2, padx = 5, pady = 5)
        
        self.C23 = Checkbutton(self.frame_content4, text = "-C", \
                 onvalue = "-C", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var23)
        self.C23.grid(row = 25, column = 0, padx = 5, pady = 5)
        self.t23=Text(self.frame_content4,height=1,width = 20)
        self.t23.grid(row = 25, column = 1, padx = 5, pady = 5)
        l23=Label(self.frame_content4, text = ':  Uses these frequencies in MHz to hop',font=self.myfont, bg="white", justify=LEFT).grid(row = 25, column = 2, padx = 5, pady = 5)
        
        self.C24 = Checkbutton(self.frame_content4, text = "-s", \
                 onvalue = "-s", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var24)
        self.C24.grid(row = 26, column = 0, padx = 5, pady = 5)
        self.t24=Text(self.frame_content4,height=1,width = 20)
        self.t24.grid(row = 26, column = 1, padx = 5, pady = 5)
        l24=Label(self.frame_content4, text = ':  same as --cswitch',font=self.myfont, bg="white", justify=LEFT).grid(row = 26, column = 2, padx = 5, pady = 5)
        
        self.C25 = Checkbutton(self.frame_content3, text = "--cswitch", \
                 onvalue = "--cswitch", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var25)
        self.C25.grid(row = 27, column = 0, padx = 5, pady = 5)
        self.t25=Text(self.frame_content3,height=1,width = 20)
        self.t25.grid(row = 27, column = 1, padx = 5, pady = 5)
        l25=Label(self.frame_content3, text = ':  Set channel switching method',font=self.myfont, bg="white", justify=LEFT).grid(row = 27, column = 2, padx = 5, pady = 5)
        
        self.C26 = Checkbutton(self.frame_content4, text = "--help", \
                 onvalue = "--help", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var26)
        self.C26.grid(row = 28, column = 0, padx = 5, pady = 5)
        self.t26=Text(self.frame_content4,height=1,width = 20)
        self.t26.grid(row = 28, column = 1, padx = 5, pady = 5)
        l26=Label(self.frame_content4, text = ':  Displays this usage screen',font=self.myfont, bg="white", justify=LEFT).grid(row = 28, column = 2, padx = 5, pady = 5)
예제 #36
0
    def __init__(self, master):
        
	self.fname=""
        #global variables
        self.t1=StringVar()
        self.t2=StringVar()
        self.t3=StringVar()
        self.t4=StringVar()
        self.t5=StringVar()
        self.t6=StringVar()
        self.t7=StringVar()
        self.t8=StringVar()
        
        self.var1=StringVar()
        self.var2=StringVar()
        self.var3=StringVar()
        self.var4=StringVar()
        self.var5=StringVar()
        self.var6=StringVar()
        self.var7=StringVar()
        self.var8=StringVar()
        #end
        
        mymaster = Frame(master, name='mymaster') # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window    
        #master.minsize(width=900, height=900)
        #master.maxsize(width=870, height=420)
        #end
        
        #title of window
        master.title("Airolib-ng")
        #end
        
        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont=tkFont.Font(family="Helvetica", size=15,underline = True)
        self.myfontnew=tkFont.Font(family="Helvetica", size=11,underline = True)
        #end
        
        
       
        nb = Notebook(mymaster, name='nb') # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3) # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1") # add tab to Notebook
    
        # repeat for each tab
        self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")
        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        
        #End
        
	#frame content 7
	Label(self.frame_content7, text = 'Airolib-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        btndetect=Button(self.frame_content7, text = 'Detect', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 1, column = 0, padx = 5, pady = 5)
		
	btndbrowse=Button(self.frame_content7, text = 'Attach File', command =self.browse_file, height=2, width=15, font=self.customFont).grid(row = 3, column = 0, padx = 5, pady = 5)	
	self.lilnew1=Listbox(self.frame_content7,bg="black", fg="white", font=self.myfont, selectmode=SINGLE, width=30, height=15)
        self.lilnew1.grid(row = 1, column = 1, rowspan=3)
	#End
	
        Label(self.frame_content, text = 'Airolib-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content, text = 'Options :',font=self.myfontnew, bg="white").grid(row = 1, column = 1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5, text = 'Edit Command From Here',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 0, column = 0)
        TextCommandBox=Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output=Text(self.frame_content5,bg="black", fg="white", font=self.myfont, height=20, width=42)
        self.output.grid(row = 0, column = 1, padx=50, pady=5, rowspan=3)
        btnsubmit=Button(self.frame_content5, width=15, height=2, text="Get Result", command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear=Button(self.frame_content5, width=15, height=2, text="Clear Output", command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "--stats", \
                 onvalue = "--stats", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var1)
        self.C1.grid(row = 2, column = 0, padx = 5, pady = 5)
        self.t1=Text(self.frame_content,height=1,width = 20)
        self.t1.grid(row = 2, column = 1, padx = 5, pady = 5)
        l1=Label(self.frame_content, text = ': Output some information about the database.',font=self.myfont, bg="white", justify=LEFT).grid(row = 2, column = 2, padx = 5, pady = 5)
        
        self.C2 = Checkbutton(self.frame_content, text = "--sql", \
                 onvalue = "--sql", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var2)
        self.C2.grid(row = 3, column = 0, padx = 5, pady = 5)
        self.t2=Text(self.frame_content,height=1,width = 20)
        self.t2.grid(row = 3, column = 1, padx = 5, pady = 5)
        l2=Label(self.frame_content, text = ': Execute the specified SQL statement.',font=self.myfont, bg="white", justify=LEFT).grid(row = 3, column = 2, padx = 5, pady = 5)
        
        self.C3 = Checkbutton(self.frame_content, text = "--clean", \
                 onvalue = "--clean", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row = 4, column = 0, padx = 5, pady = 5)
        self.t3=Text(self.frame_content,height=1,width = 20)
        self.t3.grid(row = 4, column = 1, padx = 5, pady = 5)
        l3=Label(self.frame_content, text = ':   Perform steps to clean the database from old junk.',font=self.myfont, bg="white", justify=LEFT).grid(row = 4, column = 2, padx = 5, pady = 5)
        
        self.C4 = Checkbutton(self.frame_content, text = "- -batch", \
                 onvalue = "--verify", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row = 5, column = 0, padx = 5, pady = 5)
        self.t4=Text(self.frame_content,height=1,width = 20)
        self.t4.grid(row = 5, column = 1, padx = 5, pady = 5)
        l4=Label(self.frame_content, text = ': Start batch-processing all combinations of ESSIDs and passwords.',font=self.myfont, bg="white", justify=LEFT).grid(row = 5, column = 2, padx = 5, pady = 5)
        
        self.C5 = Checkbutton(self.frame_content, text = "--verify", \
                 onvalue = "--verify", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var5)
        self.C5.grid(row = 6, column = 0, padx = 5, pady = 5)
        self.t5=Text(self.frame_content,height=1,width = 20)
        self.t5.grid(row = 6, column = 1, padx = 5, pady = 5)
        l5=Label(self.frame_content, text = ':  Verify a set of randomly chosen PMKs.',font=self.myfont, bg="white", justify=LEFT).grid(row = 6, column = 2, padx = 5, pady = 5)
        
        self.C6 = Checkbutton(self.frame_content, text = "--export", \
                 onvalue = "--export", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var6)
        self.C6.grid(row = 7, column = 0, padx = 5, pady = 5)
        self.t6=Text(self.frame_content,height=1,width = 20)
        self.t6.grid(row = 7, column = 1, padx = 5, pady = 5)
        l6=Label(self.frame_content, text = ':  Export to a cowpatty file.',font=self.myfont, bg="white", justify=LEFT).grid(row = 7, column = 2, padx = 5, pady = 5)
        
        self.C7 = Checkbutton(self.frame_content, text = "--import cowpatty", \
                 onvalue = "--import cowpatty", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var7)
        self.C7.grid(row = 8, column = 0, padx = 5, pady = 5)
        self.t7=Text(self.frame_content,height=1,width = 20)
        self.t7.grid(row = 8, column = 1, padx = 5, pady = 5)
        l7=Label(self.frame_content, text = ':  Import a cowpatty file and create the database.',font=self.myfont, bg="white", justify=LEFT).grid(row = 8, column = 2, padx = 5, pady = 5)
        
        self.C8 = Checkbutton(self.frame_content, text = "--import", \
                 onvalue = "--import", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var8)
        self.C8.grid(row = 9, column = 0, padx = 5, pady = 5)
        self.t8=Text(self.frame_content,height=1,width = 20)
        self.t8.grid(row = 9, column = 1, padx = 5, pady = 5)
        l8=Label(self.frame_content, text = ':  Import a text flat file as a list of either ESSIDs or passwords and create the database.',font=self.myfont, bg="white", justify=LEFT).grid(row = 9, column = 2, padx = 5, pady = 5)
예제 #37
0
    def __init__(self, master, container):

        self.master = master
        master.title("nicMSlesions")

        # running on a container
        self.container = container

        # gui attributes
        self.path = os.getcwd()
        self.default_config = None
        self.user_config = None
        self.current_folder = os.getcwd()
        self.list_train_pretrained_nets = []
        self.list_test_nets = []
        self.version = __version__
        if self.container is False:
            # version_number
            self.commit_version = subprocess.check_output(
                ['git', 'rev-parse', 'HEAD'])

        # queue and thread parameters. All processes are embedded
        # inside threads to avoid freezing the application
        self.train_task = None
        self.test_task = None
        self.test_queue = Queue.Queue()
        self.train_queue = Queue.Queue()

        # --------------------------------------------------
        # parameters. Mostly from the config/*.cfg files
        # --------------------------------------------------

        # data parameters
        self.param_training_folder = StringVar()
        self.param_test_folder = StringVar()
        self.param_FLAIR_tag = StringVar()
        self.param_T1_tag = StringVar()
        self.param_MOD3_tag = StringVar()
        self.param_MOD4_tag = StringVar()
        self.param_mask_tag = StringVar()
        self.param_model_tag = StringVar()
        self.param_register_modalities = BooleanVar()
        self.param_skull_stripping = BooleanVar()
        self.param_denoise = BooleanVar()
        self.param_denoise_iter = IntVar()
        self.param_save_tmp = BooleanVar()
        self.param_debug = BooleanVar()

        # train parameters
        self.param_net_folder = os.path.join(self.current_folder, 'nets')
        self.param_use_pretrained_model = BooleanVar()
        self.param_pretrained_model = StringVar()
        self.param_inference_model = StringVar()
        self.param_num_layers = IntVar()
        self.param_net_name = StringVar()
        self.param_net_name.set('None')
        self.param_balanced_dataset = StringVar()
        self.param_fract_negatives = DoubleVar()

        # model parameters
        self.param_pretrained = None
        self.param_min_th = DoubleVar()
        self.param_patch_size = IntVar()
        self.param_weight_paths = StringVar()
        self.param_load_weights = BooleanVar()
        self.param_train_split = DoubleVar()
        self.param_max_epochs = IntVar()
        self.param_patience = IntVar()
        self.param_batch_size = IntVar()
        self.param_net_verbose = IntVar()
        self.param_t_bin = DoubleVar()
        self.param_l_min = IntVar()
        self.param_min_error = DoubleVar()
        self.param_mode = BooleanVar()
        self.param_gpu_number = IntVar()

        # load the default configuration from the conf file
        self.load_default_configuration()

        # self frame (tabbed notebook)
        self.note = Notebook(self.master)
        self.note.pack()

        os.system('cls' if platform.system() == 'Windows' else 'clear')
        print "##################################################"
        print "# ------------                                   #"
        print "# nicMSlesions                                   #"
        print "# ------------                                   #"
        print "# MS WM lesion segmentation                      #"
        print "#                                                #"
        print "# -------------------------------                #"
        print "# (c) Sergi Valverde 2018                        #"
        print "# Neuroimage Computing Group                     #"
        print "# -------------------------------                #"
        print "##################################################\n"
        print "Please select options for training or inference in the menu..."

        # --------------------------------------------------
        # training tab
        # --------------------------------------------------
        self.train_frame = Frame()
        self.note.add(self.train_frame, text="Training")
        self.test_frame = Frame()
        self.note.add(self.test_frame, text="Inference")

        # label frames
        cl_s = 5
        self.tr_frame = LabelFrame(self.train_frame, text="Training images:")
        self.tr_frame.grid(row=0,
                           columnspan=cl_s,
                           sticky='WE',
                           padx=5,
                           pady=5,
                           ipadx=5,
                           ipady=5)
        self.model_frame = LabelFrame(self.train_frame, text="CNN model:")
        self.model_frame.grid(row=5,
                              columnspan=cl_s,
                              sticky='WE',
                              padx=5,
                              pady=5,
                              ipadx=5,
                              ipady=5)

        # training options
        self.inFolderLbl = Label(self.tr_frame, text="Training folder:")
        self.inFolderLbl.grid(row=0, column=0, sticky='E', padx=5, pady=2)
        self.inFolderTxt = Entry(self.tr_frame)
        self.inFolderTxt.grid(row=0,
                              column=1,
                              columnspan=5,
                              sticky="W",
                              pady=3)
        self.inFileBtn = Button(self.tr_frame,
                                text="Browse ...",
                                command=self.load_training_path)
        self.inFileBtn.grid(row=0,
                            column=5,
                            columnspan=1,
                            sticky='W',
                            padx=5,
                            pady=1)

        self.optionsBtn = Button(self.tr_frame,
                                 text="Other options",
                                 command=self.parameter_window)
        self.optionsBtn.grid(row=0,
                             column=10,
                             columnspan=1,
                             sticky="W",
                             padx=(100, 1),
                             pady=1)

        # setting input modalities: FLAIR + T1 are mandatory
        # Mod 3 / 4 are optional
        self.flairTagLbl = Label(self.tr_frame, text="FLAIR tag:")
        self.flairTagLbl.grid(row=1, column=0, sticky='E', padx=5, pady=2)
        self.flairTxt = Entry(self.tr_frame, textvariable=self.param_FLAIR_tag)
        self.flairTxt.grid(row=1, column=1, columnspan=1, sticky="W", pady=1)

        self.t1TagLbl = Label(self.tr_frame, text="T1 tag:")
        self.t1TagLbl.grid(row=2, column=0, sticky='E', padx=5, pady=2)
        self.t1Txt = Entry(self.tr_frame, textvariable=self.param_T1_tag)
        self.t1Txt.grid(row=2, column=1, columnspan=1, sticky="W", pady=1)

        self.mod3TagLbl = Label(self.tr_frame, text="mod 3 tag:")
        self.mod3TagLbl.grid(row=3, column=0, sticky='E', padx=5, pady=2)
        self.mod3Txt = Entry(self.tr_frame, textvariable=self.param_MOD3_tag)
        self.mod3Txt.grid(row=3, column=1, columnspan=1, sticky="W", pady=1)

        self.mod4TagLbl = Label(self.tr_frame, text="mod 4 tag:")
        self.mod4TagLbl.grid(row=4, column=0, sticky='E', padx=5, pady=2)
        self.mod4Txt = Entry(self.tr_frame, textvariable=self.param_MOD4_tag)
        self.mod4Txt.grid(row=4, column=1, columnspan=1, sticky="W", pady=1)

        self.maskTagLbl = Label(self.tr_frame, text="MASK tag:")
        self.maskTagLbl.grid(row=5, column=0, sticky='E', padx=5, pady=2)
        self.maskTxt = Entry(self.tr_frame, textvariable=self.param_mask_tag)
        self.maskTxt.grid(row=5, column=1, columnspan=1, sticky="W", pady=1)

        # model options
        self.modelTagLbl = Label(self.model_frame, text="Model name:")
        self.modelTagLbl.grid(row=6, column=0, sticky='E', padx=5, pady=2)
        self.modelTxt = Entry(self.model_frame,
                              textvariable=self.param_net_name)
        self.modelTxt.grid(row=6, column=1, columnspan=1, sticky="W", pady=1)

        self.checkPretrain = Checkbutton(self.model_frame,
                                         text="use pretrained",
                                         var=self.param_use_pretrained_model)
        self.checkPretrain.grid(row=6, column=3, padx=5, pady=5)

        self.update_pretrained_nets()

        self.pretrainTxt = OptionMenu(self.model_frame,
                                      self.param_pretrained_model,
                                      *self.list_train_pretrained_nets)
        self.pretrainTxt.grid(row=6, column=5, sticky='E', padx=5, pady=5)

        # START button links
        self.trainingBtn = Button(self.train_frame,
                                  state='disabled',
                                  text="Start training",
                                  command=self.train_net)
        self.trainingBtn.grid(row=7, column=0, sticky='W', padx=1, pady=1)

        # --------------------------------------------------
        # inference tab
        # --------------------------------------------------
        self.tt_frame = LabelFrame(self.test_frame, text="Inference images:")
        self.tt_frame.grid(row=0,
                           columnspan=cl_s,
                           sticky='WE',
                           padx=5,
                           pady=5,
                           ipadx=5,
                           ipady=5)
        self.test_model_frame = LabelFrame(self.test_frame, text="CNN model:")
        self.test_model_frame.grid(row=5,
                                   columnspan=cl_s,
                                   sticky='WE',
                                   padx=5,
                                   pady=5,
                                   ipadx=5,
                                   ipady=5)

        # testing options
        self.test_inFolderLbl = Label(self.tt_frame, text="Testing folder:")
        self.test_inFolderLbl.grid(row=0, column=0, sticky='E', padx=5, pady=2)
        self.test_inFolderTxt = Entry(self.tt_frame)
        self.test_inFolderTxt.grid(row=0,
                                   column=1,
                                   columnspan=5,
                                   sticky="W",
                                   pady=3)
        self.test_inFileBtn = Button(self.tt_frame,
                                     text="Browse ...",
                                     command=self.load_testing_path)
        self.test_inFileBtn.grid(row=0,
                                 column=5,
                                 columnspan=1,
                                 sticky='W',
                                 padx=5,
                                 pady=1)

        self.test_optionsBtn = Button(self.tt_frame,
                                      text="Other options",
                                      command=self.parameter_window)
        self.test_optionsBtn.grid(row=0,
                                  column=10,
                                  columnspan=1,
                                  sticky="W",
                                  padx=(100, 1),
                                  pady=1)

        self.test_flairTagLbl = Label(self.tt_frame, text="FLAIR tag:")
        self.test_flairTagLbl.grid(row=1, column=0, sticky='E', padx=5, pady=2)
        self.test_flairTxt = Entry(self.tt_frame,
                                   textvariable=self.param_FLAIR_tag)
        self.test_flairTxt.grid(row=1,
                                column=1,
                                columnspan=1,
                                sticky="W",
                                pady=1)

        self.test_t1TagLbl = Label(self.tt_frame, text="T1 tag:")
        self.test_t1TagLbl.grid(row=2, column=0, sticky='E', padx=5, pady=2)
        self.test_t1Txt = Entry(self.tt_frame, textvariable=self.param_T1_tag)
        self.test_t1Txt.grid(row=2, column=1, columnspan=1, sticky="W", pady=1)

        self.test_mod3TagLbl = Label(self.tt_frame, text="mod 3 tag:")
        self.test_mod3TagLbl.grid(row=3, column=0, sticky='E', padx=5, pady=2)
        self.test_mod3Txt = Entry(self.tt_frame,
                                  textvariable=self.param_MOD3_tag)
        self.test_mod3Txt.grid(row=3,
                               column=1,
                               columnspan=1,
                               sticky="W",
                               pady=1)

        self.test_mod4TagLbl = Label(self.tt_frame, text="mod 4 tag:")
        self.test_mod4TagLbl.grid(row=4, column=0, sticky='E', padx=5, pady=2)
        self.test_mod4Txt = Entry(self.tt_frame,
                                  textvariable=self.param_MOD4_tag)
        self.test_mod4Txt.grid(row=4,
                               column=1,
                               columnspan=1,
                               sticky="W",
                               pady=1)

        self.test_pretrainTxt = OptionMenu(self.test_model_frame,
                                           self.param_inference_model,
                                           *self.list_test_nets)

        self.param_inference_model.set('None')
        self.test_pretrainTxt.grid(row=5, column=0, sticky='E', padx=5, pady=5)

        # START button links cto docker task
        self.inferenceBtn = Button(self.test_frame,
                                   state='disabled',
                                   text="Start inference",
                                   command=self.infer_segmentation)
        self.inferenceBtn.grid(row=7, column=0, sticky='W', padx=1, pady=1)

        # train / test ABOUT button
        self.train_aboutBtn = Button(self.train_frame,
                                     text="about",
                                     command=self.about_window)
        self.train_aboutBtn.grid(row=7,
                                 column=4,
                                 sticky='E',
                                 padx=(1, 1),
                                 pady=1)

        self.test_aboutBtn = Button(self.test_frame,
                                    text="about",
                                    command=self.about_window)
        self.test_aboutBtn.grid(row=7,
                                column=4,
                                sticky='E',
                                padx=(1, 1),
                                pady=1)

        # Processing state
        self.process_indicator = StringVar()
        self.process_indicator.set(' ')
        self.label_indicator = Label(master,
                                     textvariable=self.process_indicator)
        self.label_indicator.pack(side="left")

        # Closing processing events is implemented via
        # a master protocol
        self.master.protocol("WM_DELETE_WINDOW", self.close_event)
예제 #38
0
def report_storage(master, cathegory=-1, item=None):
    """Создает и выводи на экран окно с отчетом по остаткам"""


    def press(index):
        """функция, срабатывающая при нажатии кнопок переключения
        между видами сортировок. Переключает вкладки в блокноте"""

        window_names = tabs.tabs()
        tabs.select(window_names[index])


    def make_query_storage(cathegory=-1, item=None):
        """Возвращает кортеж запросов для последующего использования при
        составлении отчета по остаткам"""

        select = queries.report_storage_query()

        if cathegory <> -1:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.cathegory == cathegory:
                        new_select.append(element)
                select[q] = new_select

        if item:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element == item:
                        new_select.append(element)
                select[q] = new_select

        return select


    def show(frame, iterator):
        """Выводит на экран выборку, заданную в iterator"""

        scrollbar = Scrollbar(frame)
        tree = Treeview(frame, selectmode='none', padding=3,
                                    style='Custom.Treeview', height=REPORT_HEIGHT,
                                    yscrollcommand=scrollbar.set)
        tree.pack(side=LEFT, fill=BOTH, expand=YES)
        scrollbar.config(command=tree.yview)
        scrollbar.pack(side=LEFT, fill=Y)

        tree.tag_configure('1', font=('Verdana', FONT_SIZE_REPORT))
        tree.tag_configure('2', font=('Verdana', FONT_SIZE_REPORT),
                                                           background='#f5f5ff')
        tree.tag_configure('red1', font=('Verdana', FONT_SIZE_REPORT),
                                                               foreground='red')
        tree.tag_configure('red2', font=('Verdana', FONT_SIZE_REPORT),
                                         background='#f5f5ff', foreground='red')
        tree.tag_configure('grey1', font=('Verdana', FONT_SIZE_REPORT),
                                                              foreground='#dddddd')
        tree.tag_configure('grey2', font=('Verdana', FONT_SIZE_REPORT),
                                        background='#f5f5ff', foreground='#dddddd')

        Style().configure('Custom.Treeview', rowheight=FONT_SIZE_REPORT*2)

        columns = ['#' + str(x + 1) for x in range(4)]
        tree.configure(columns=columns)

        for q in range(len(header)):
            tree.heading('#%d' % (q + 1), text=header[q], anchor='w')
            tree.column('#%d' % (q + 1), width=REPORT_SCALE * col_width[q + 1],
                                                                     anchor='w')
        tree.heading('#0', text='', anchor='w')
        tree.column('#0', width=0, anchor='w', minwidth=0)

        flag = True
        for item in iterator:
            if not item.calculation:
                col = []
                col.append(add_s(item.cathegory.name if item.cathegory
                                                                 else u'-Нет-'))
                col.append(add_s(item.name))
                storage = queries.items_in_storage(item)
                col.append(add_s(storage))
                col.append(add_s(item.measure))
                if int(storage) > 0:
                    flag = not flag
                    if flag:
                        tree.insert('', 'end', text='', values=col, tag='2')
                    else:
                        tree.insert('', 'end', text='', values=col, tag='1')
                elif storage == '0':
                    flag = not flag
                    if flag:
                        tree.insert('', 'end', text='', values=col, tag='grey2')
                    else:
                        tree.insert('', 'end', text='', values=col, tag='grey1')
                else:
                    flag = not flag
                    if flag:
                        tree.insert('', 'end', text='', values=col, tag='red2')
                    else:
                        tree.insert('', 'end', text='', values=col, tag='red1')


    # --------------------------------------------#

    tl = Toplevel(master)
    tl.title(u'Отчет по остаткам')

    bottom = Frame(tl, relief=SUNKEN)
    bottom.pack(side=BOTTOM, fill=X)

    showArea = []
    tabs = Notebook(tl, style='Hidden.TNotebook')
    for q in range (2):
        frame = Frame(tabs,  height=REPORT_HEIGHT)
        tabs.add(frame, text='')
        showArea.append(frame)
    tabs.pack(side=TOP, fill=BOTH, expand=YES)
    Style().layout('Hidden.TNotebook.Tab', '')

    header = [u'Категория', u'Товар', u'Кол-во', u'Ед.изм.']

    col_width = (0, 15, 38, 14, 8)

    query = make_query_storage(cathegory, item)
    for q in range(len(query)):
        summ = show(showArea[q], query[q])


    Button(bottom, text=u'Сортировка\nпо категории', command=lambda: press(0)
                             ).pack(side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Сортировка\nпо товару', command=lambda:press(1)).pack(
                                    side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Экспорт в\nMS Excel').pack(
                                   side=RIGHT, padx=REPORT_PAD, pady=REPORT_PAD)

    tl.focus_set()
예제 #39
0
    def __init__(self, master):
	
	self.fname=""        
        #global variables
        self.t1=StringVar()
        self.t2=StringVar()
        self.t3=StringVar()
        self.t4=StringVar()
        self.t5=StringVar()
        self.t6=StringVar()
        self.t7=StringVar()
        self.t8=StringVar()
        self.t9=StringVar()
        self.t10=StringVar()
        
        self.var1=StringVar()
        self.var2=StringVar()
        self.var3=StringVar()
        self.var4=StringVar()
        self.var5=StringVar()
        self.var6=StringVar()
        self.var7=StringVar()
        self.var8=StringVar()
        self.var9=StringVar()
        self.var10=StringVar()
        #end
        
        mymaster = Frame(master, name='mymaster') # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window    
        #master.minsize(width=900, height=900)
        #master.maxsize(width=650, height=500)
        #end
        
        #title of window
        master.title("Airdrop-ng")
        #end
        
        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont=tkFont.Font(family="Helvetica", size=15,underline = True)
        self.myfontnew=tkFont.Font(family="Helvetica", size=11,underline = True)
        #end
        
        
       
        nb = Notebook(mymaster, name='nb') # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3) # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1") # add tab to Notebook
	self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")
    
        # repeat for each tab
        
        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        
        #End
        
	#frame content 7
	Label(self.frame_content7, text = 'Airdrop-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        btndetect=Button(self.frame_content7, text = 'Detect', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 1, column = 0, padx = 5, pady = 5)
		
	btndbrowse=Button(self.frame_content7, text = 'Attach File', command =self.browse_file, height=2, width=15, font=self.customFont).grid(row = 3, column = 0, padx = 5, pady = 5)	
	self.lilnew1=Listbox(self.frame_content7,bg="black", fg="white", font=self.myfont, selectmode=SINGLE, width=30, height=15)
        self.lilnew1.grid(row = 1, column = 1, rowspan=3)
	#End
	
        Label(self.frame_content, text = 'Airdrop-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content, text = 'Options :',font=self.myfontnew, bg="white").grid(row = 1, column = 1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5, text = 'Edit Command From Here',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 0, column = 0)
        TextCommandBox=Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output=Text(self.frame_content5,bg="black", fg="white", font=self.myfont, height=20, width=42)
        self.output.grid(row = 0, column = 1, padx=50, pady=5, rowspan=3)
        btnsubmit=Button(self.frame_content5, width=15, height=2, text="Get Result", command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear=Button(self.frame_content5, width=15, height=2, text="Clear Output", command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "-i", \
                 onvalue = "-i", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var1)
        self.C1.grid(row = 2, column = 0, padx = 5, pady = 5)
        self.t1=Text(self.frame_content,height=1,width = 20)
        self.t1.grid(row = 2, column = 1, padx = 5, pady = 5)
        l1=Label(self.frame_content, text = ': Wireless card in monitor mode to inject from',font=self.myfont, bg="white", justify=LEFT).grid(row = 2, column = 2, padx = 5, pady = 5)
        
        self.C2 = Checkbutton(self.frame_content, text = "-t", \
                 onvalue = "-t", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var2)
        self.C2.grid(row = 3, column = 0, padx = 5, pady = 5)
        self.t2=Text(self.frame_content,height=1,width = 20)
        self.t2.grid(row = 3, column = 1, padx = 5, pady = 5)
        l2=Label(self.frame_content, text = ': Airodump txt file in CSV format NOT the pcap',font=self.myfont, bg="white", justify=LEFT).grid(row = 3, column = 2, padx = 5, pady = 5)
        
        self.C3 = Checkbutton(self.frame_content, text = "-p", \
                 onvalue = "-p", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row = 4, column = 0, padx = 5, pady = 5)
        self.t3=Text(self.frame_content,height=1,width = 20)
        self.t3.grid(row = 4, column = 1, padx = 5, pady = 5)
        l3=Label(self.frame_content, text = ': Disable the use of Psyco JIT',font=self.myfont, bg="white", justify=LEFT).grid(row = 4, column = 2, padx = 5, pady = 5)
        
        self.C4 = Checkbutton(self.frame_content, text = "-r", \
                 onvalue = "-r", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row = 5, column = 0, padx = 5, pady = 5)
        self.t4=Text(self.frame_content,height=1,width = 20)
        self.t4.grid(row = 5, column = 1, padx = 5, pady = 5)
        l4=Label(self.frame_content, text = ': Rule File for matched deauths)',font=self.myfont, bg="white", justify=LEFT).grid(row = 5, column = 2, padx = 5, pady = 5)
        
        self.C5 = Checkbutton(self.frame_content, text = "-u", \
                 onvalue = "-u", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var5)
        self.C5.grid(row = 6, column = 0, padx = 5, pady = 5)
        self.t5=Text(self.frame_content,height=1,width = 20)
        self.t5.grid(row = 6, column = 1, padx = 5, pady = 5)
        l5=Label(self.frame_content, text = ': Updates OUI list.',font=self.myfont, bg="white", justify=LEFT).grid(row = 6, column = 2, padx = 5, pady = 5)
        
        self.C6 = Checkbutton(self.frame_content, text = "-d", \
                 onvalue = "-d", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var6)
        self.C6.grid(row = 8, column = 0, padx = 5, pady = 5)
        self.t6=Text(self.frame_content,height=1,width = 20)
        self.t6.grid(row = 8, column = 1, padx = 5, pady = 5)
        l6=Label(self.frame_content, text = ': Injection driver. Default is mac80211.',font=self.myfont, bg="white", justify=LEFT).grid(row = 8, column = 2, padx = 5, pady = 5)
        
        self.C7 = Checkbutton(self.frame_content, text = "-s", \
                 onvalue = "-s", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var7)
        self.C7.grid(row = 9, column = 0, padx = 5, pady = 5)
        self.t7=Text(self.frame_content,height=1,width = 20)
        self.t7.grid(row = 9, column = 1, padx = 5, pady = 5)
        l7=Label(self.frame_content, text = ': Time to sleep between sending each packet',font=self.myfont, bg="white", justify=LEFT).grid(row = 9, column = 2, padx = 5, pady = 5)
        
        self.C8 = Checkbutton(self.frame_content, text = "-b", \
                onvalue = "-b", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var8)
        self.C8.grid(row = 10, column = 0, padx = 5, pady = 5)
        self.t8=Text(self.frame_content,height=1,width = 20)
        self.t8.grid(row = 10, column = 1, padx = 5, pady = 5)
        l8=Label(self.frame_content, text = ': Turn on Rule Debugging',font=self.myfont, bg="white", justify=LEFT).grid(row = 10, column = 2, padx = 5, pady = 5)
        
        self.C9 = Checkbutton(self.frame_content, text = "-l", \
                onvalue = "-l", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var9)
        self.C9.grid(row = 11, column = 0, padx = 5, pady = 5)
        self.t9=Text(self.frame_content,height=1,width = 20)
        self.t9.grid(row = 11, column = 1, padx = 5, pady = 5)
        l9=Label(self.frame_content, text = ': Enable Logging to a file',font=self.myfont, bg="white", justify=LEFT).grid(row = 11, column = 2, padx = 5, pady = 5)
        
        self.C10 = Checkbutton(self.frame_content, text = "-n", \
                onvalue = "-n", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var10)
        self.C10.grid(row = 12, column = 0, padx = 5, pady = 5)
        self.t10=Text(self.frame_content,height=1,width = 20)
        self.t10.grid(row = 12, column = 1, padx = 5, pady = 5)
        l10=Label(self.frame_content, text = ': Time to sleep between loops',font=self.myfont, bg="white", justify=LEFT).grid(row = 12, column = 2, padx = 5, pady = 5)
예제 #40
0
    cols = ['A', 'B', 'AsB', 'BsA','AuB','AiB','AsBdB','BsAdA','lcs','wordorder','semantic','nounphrase','tfidf','onehot','char2','char3','char4','word1','word2','word3','lemma1','lemma2','lemma3','posgm1','posgm2','posgm3']
    test = pd.read_csv(d+f+"/combined.csv")
    filename = d+'models/model.sav'
    model = joblib.load(filename)
    testArr = test.as_matrix(cols)
    results = model.predict(testArr)
    test['predictions'] = results
    text.configure(state="normal")
    text.delete('1.0',END)
    text.insert(INSERT,results)
    text.configure(state="disabled")
root = Tk()
root.configure(background='teal')
root.title("Syntactic Textual Similarity")
root.resizable(width=False, height=False)
note = Notebook(root)

frame = Frame(root)

queryvar = StringVar()
ql = StringVar()
frame.grid(row=4,column=0,rowspan=12,columnspan=3,pady=20)
text = ScrolledText(frame,wrap="word")
text.grid(row=4)
text.config(font=("Courier", 12))
text.configure(background='black',foreground='green')
directory = StringVar()
filename = StringVar()
sent1 = StringVar()
sent2 = StringVar()
status = StringVar()
예제 #41
0
 def destroy(self):
   self.crawler.quit()
   Notebook.destroy(self)
예제 #42
0
	def __init__(self, parent):
		self.root = Notebook(parent)
		self.frames = {}
예제 #43
0
파일: view.py 프로젝트: oguntli/bugjar
class MainWindow(object):
    def __init__(self, root, debugger):
        '''
        -----------------------------------------------------
        | main button toolbar                               |
        -----------------------------------------------------
        |       < ma | in content area >      |             |
        |            |                        |             |
        | File list  | File name              | Inspector   |
        | (stack/    | Code area              |             |
        | breakpnts) |                        |             |
        |            |                        |             |
        |            |                        |             |
        -----------------------------------------------------
        |     status bar area                               |
        -----------------------------------------------------

        '''

        # Obtain and expand the current working directory.
        base_path = os.path.abspath(os.getcwd())
        base_path = os.path.normcase(base_path) + '/'

        # Create a filename normalizer based on the CWD.
        self.filename_normalizer = filename_normalizer(base_path)

        self.debugger = debugger
        # Associate the debugger with this view.
        self.debugger.view = self

        # Root window
        self.root = root
        self.root.title('Bugjar')
        self.root.geometry('1024x768')

        # Prevent the menus from having the empty tearoff entry
        self.root.option_add('*tearOff', False)
        # Catch the close button
        self.root.protocol("WM_DELETE_WINDOW", self.cmd_quit)
        # Catch the "quit" event.
        self.root.createcommand('exit', self.cmd_quit)

        # Setup the menu
        self._setup_menubar()

        # Set up the main content for the window.
        self._setup_button_toolbar()
        self._setup_main_content()
        self._setup_status_bar()

        # Now configure the weights for the root frame
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=0)
        self.root.rowconfigure(1, weight=1)
        self.root.rowconfigure(2, weight=0)

        debugger.start()

    ######################################################
    # Internal GUI layout methods.
    ######################################################

    def _setup_menubar(self):
        # Menubar
        self.menubar = Menu(self.root)

        # self.menu_Apple = Menu(self.menubar, name='Apple')
        # self.menubar.add_cascade(menu=self.menu_Apple)

        self.menu_file = Menu(self.menubar)
        self.menubar.add_cascade(menu=self.menu_file, label='File')

        self.menu_program = Menu(self.menubar)
        self.menubar.add_cascade(menu=self.menu_program, label='Program')

        self.menu_help = Menu(self.menubar)
        self.menubar.add_cascade(menu=self.menu_help, label='Help')

        # self.menu_Apple.add_command(label='Test', command=self.cmd_dummy)

        # self.menu_file.add_command(label='New', command=self.cmd_dummy, accelerator="Command-N")
        self.menu_file.add_command(label='Open...',
                                   command=self.cmd_open_file,
                                   accelerator="Command-O")
        self.root.bind('<Command-o>', self.cmd_open_file)
        # self.menu_file.add_command(label='Close', command=self.cmd_dummy)

        self.menu_program.add_command(label='Run',
                                      command=self.cmd_run,
                                      accelerator="R")
        self.root.bind('<r>', self.cmd_run)
        self.menu_program.add_command(label='Step',
                                      command=self.cmd_step,
                                      accelerator="S")
        self.root.bind('<s>', self.cmd_step)
        self.menu_program.add_command(label='Next',
                                      command=self.cmd_next,
                                      accelerator="N")
        self.root.bind('<n>', self.cmd_next)
        self.menu_program.add_command(label='Return',
                                      command=self.cmd_return,
                                      accelerator="BackSpace")
        self.root.bind('<BackSpace>', self.cmd_return)

        self.menu_help.add_command(label='Open Documentation',
                                   command=self.cmd_bugjar_docs)
        self.menu_help.add_command(label='Open Bugjar project page',
                                   command=self.cmd_bugjar_page)
        self.menu_help.add_command(label='Open Bugjar on GitHub',
                                   command=self.cmd_bugjar_github)
        self.menu_help.add_command(label='Open BeeWare project page',
                                   command=self.cmd_beeware_page)

        # last step - configure the menubar
        self.root['menu'] = self.menubar

    def _setup_button_toolbar(self):
        '''
        The button toolbar runs as a horizontal area at the top of the GUI.
        It is a persistent GUI component
        '''

        # Main toolbar
        self.toolbar = Frame(self.root)
        self.toolbar.grid(column=0, row=0, sticky=(W, E))

        # Buttons on the toolbar
        self.run_button = Button(self.toolbar,
                                 text='Run',
                                 command=self.cmd_run)
        self.run_button.grid(column=0, row=0)

        self.step_button = Button(self.toolbar,
                                  text='Step',
                                  command=self.cmd_step)
        self.step_button.grid(column=1, row=0)

        self.next_button = Button(self.toolbar,
                                  text='Next',
                                  command=self.cmd_next)
        self.next_button.grid(column=2, row=0)

        self.return_button = Button(self.toolbar,
                                    text='Return',
                                    command=self.cmd_return)
        self.return_button.grid(column=3, row=0)

        self.toolbar.columnconfigure(0, weight=0)
        self.toolbar.rowconfigure(0, weight=0)

    def _setup_main_content(self):
        '''
        Sets up the main content area. It is a persistent GUI component
        '''

        # Main content area
        self.content = PanedWindow(self.root, orient=HORIZONTAL)
        self.content.grid(column=0, row=1, sticky=(N, S, E, W))

        # Create subregions of the content
        self._setup_file_lists()
        self._setup_code_area()
        self._setup_inspector()

        # Set up weights for the left frame's content
        self.content.columnconfigure(0, weight=1)
        self.content.rowconfigure(0, weight=1)

        self.content.pane(0, weight=1)
        self.content.pane(1, weight=2)
        self.content.pane(2, weight=1)

    def _setup_file_lists(self):

        self.file_notebook = Notebook(self.content, padding=(0, 5, 0, 5))
        self.content.add(self.file_notebook)

        self._setup_stack_frame_list()
        self._setup_breakpoint_list()

    def _setup_stack_frame_list(self):
        self.stack_frame = Frame(self.content)
        self.stack_frame.grid(column=0, row=0, sticky=(N, S, E, W))
        self.file_notebook.add(self.stack_frame, text='Stack')

        self.stack = StackView(self.stack_frame,
                               normalizer=self.filename_normalizer)
        self.stack.grid(column=0, row=0, sticky=(N, S, E, W))

        # # The tree's vertical scrollbar
        self.stack_scrollbar = Scrollbar(self.stack_frame, orient=VERTICAL)
        self.stack_scrollbar.grid(column=1, row=0, sticky=(N, S))

        # # Tie the scrollbar to the text views, and the text views
        # # to each other.
        self.stack.config(yscrollcommand=self.stack_scrollbar.set)
        self.stack_scrollbar.config(command=self.stack.yview)

        # Setup weights for the "stack" tree
        self.stack_frame.columnconfigure(0, weight=1)
        self.stack_frame.columnconfigure(1, weight=0)
        self.stack_frame.rowconfigure(0, weight=1)

        # Handlers for GUI events
        self.stack.bind('<<TreeviewSelect>>', self.on_stack_frame_selected)

    def _setup_breakpoint_list(self):
        self.breakpoints_frame = Frame(self.content)
        self.breakpoints_frame.grid(column=0, row=0, sticky=(N, S, E, W))
        self.file_notebook.add(self.breakpoints_frame, text='Breakpoints')

        self.breakpoints = BreakpointView(self.breakpoints_frame,
                                          normalizer=self.filename_normalizer)
        self.breakpoints.grid(column=0, row=0, sticky=(N, S, E, W))

        # The tree's vertical scrollbar
        self.breakpoints_scrollbar = Scrollbar(self.breakpoints_frame,
                                               orient=VERTICAL)
        self.breakpoints_scrollbar.grid(column=1, row=0, sticky=(N, S))

        # Tie the scrollbar to the text views, and the text views
        # to each other.
        self.breakpoints.config(yscrollcommand=self.breakpoints_scrollbar.set)
        self.breakpoints_scrollbar.config(command=self.breakpoints.yview)

        # Setup weights for the "breakpoint list" tree
        self.breakpoints_frame.columnconfigure(0, weight=1)
        self.breakpoints_frame.columnconfigure(1, weight=0)
        self.breakpoints_frame.rowconfigure(0, weight=1)

        # Handlers for GUI events
        self.breakpoints.tag_bind('breakpoint', '<Double-Button-1>',
                                  self.on_breakpoint_double_clicked)
        self.breakpoints.tag_bind('breakpoint', '<<TreeviewSelect>>',
                                  self.on_breakpoint_selected)
        self.breakpoints.tag_bind('file', '<<TreeviewSelect>>',
                                  self.on_breakpoint_file_selected)

    def _setup_code_area(self):
        self.code_frame = Frame(self.content)
        self.code_frame.grid(column=1, row=0, sticky=(N, S, E, W))

        # Label for current file
        self.current_file = StringVar()
        self.current_file_label = Label(self.code_frame,
                                        textvariable=self.current_file)
        self.current_file_label.grid(column=0, row=0, sticky=(W, E))

        # Code display area
        self.code = DebuggerCode(self.code_frame, debugger=self.debugger)
        self.code.grid(column=0, row=1, sticky=(N, S, E, W))

        # Set up weights for the code frame's content
        self.code_frame.columnconfigure(0, weight=1)
        self.code_frame.rowconfigure(0, weight=0)
        self.code_frame.rowconfigure(1, weight=1)

        self.content.add(self.code_frame)

    def _setup_inspector(self):
        self.inspector_frame = Frame(self.content)
        self.inspector_frame.grid(column=2, row=0, sticky=(N, S, E, W))

        self.inspector = InspectorView(self.inspector_frame)
        self.inspector.grid(column=0, row=0, sticky=(N, S, E, W))

        # The tree's vertical scrollbar
        self.inspector_scrollbar = Scrollbar(self.inspector_frame,
                                             orient=VERTICAL)
        self.inspector_scrollbar.grid(column=1, row=0, sticky=(N, S))

        # Tie the scrollbar to the text views, and the text views
        # to each other.
        self.inspector.config(yscrollcommand=self.inspector_scrollbar.set)
        self.inspector_scrollbar.config(command=self.inspector.yview)

        # Setup weights for the "breakpoint list" tree
        self.inspector_frame.columnconfigure(0, weight=1)
        self.inspector_frame.columnconfigure(1, weight=0)
        self.inspector_frame.rowconfigure(0, weight=1)

        self.content.add(self.inspector_frame)

    def _setup_status_bar(self):
        # Status bar
        self.statusbar = Frame(self.root)
        self.statusbar.grid(column=0, row=2, sticky=(W, E))

        # Current status
        self.run_status = StringVar()
        self.run_status_label = Label(self.statusbar,
                                      textvariable=self.run_status)
        self.run_status_label.grid(column=0, row=0, sticky=(W, E))
        self.run_status.set('Not running')

        # Main window resize handle
        self.grip = Sizegrip(self.statusbar)
        self.grip.grid(column=1, row=0, sticky=(S, E))

        # Set up weights for status bar frame
        self.statusbar.columnconfigure(0, weight=1)
        self.statusbar.columnconfigure(1, weight=0)
        self.statusbar.rowconfigure(0, weight=0)

    ######################################################
    # Utility methods for controlling content
    ######################################################

    def show_file(self, filename, line=None, breakpoints=None):
        """Show the content of the nominated file.

        If specified, line is the current line number to highlight. If the
        line isn't currently visible, the window will be scrolled until it is.

        breakpoints is a list of line numbers that have current breakpoints.

        If refresh is true, the file will be reloaded and redrawn.
        """
        # Set the filename label for the current file
        self.current_file.set(self.filename_normalizer(filename))

        # Update the code view; this means changing the displayed file
        # if necessary, and updating the current line.
        if filename != self.code.filename:
            self.code.filename = filename
            for bp in self.debugger.breakpoints(filename).values():
                if bp.enabled:
                    self.code.enable_breakpoint(bp.line)
                else:
                    self.code.disable_breakpoint(bp.line)

        self.code.line = line

    ######################################################
    # TK Main loop
    ######################################################

    def mainloop(self):
        self.root.mainloop()

    ######################################################
    # TK Command handlers
    ######################################################

    def cmd_quit(self):
        "Quit the debugger"
        self.debugger.stop()
        self.root.quit()

    def cmd_run(self, event=None):
        "Run until the next breakpoint, or end of execution"
        self.debugger.do_run()

    def cmd_step(self, event=None):
        "Step into the next line of code"
        self.debugger.do_step()

    def cmd_next(self, event=None):
        "Run the next line of code in the current frame"
        self.debugger.do_next()

    def cmd_return(self, event=None):
        "Return to the previous frame"
        self.debugger.do_return()

    def cmd_open_file(self, event=None):
        "Open a file in the breakpoint pane"
        filename = tkFileDialog.askopenfilename(
            initialdir=os.path.abspath(os.getcwd()))

        if filename:
            # Convert to canonical form
            filename = os.path.abspath(filename)
            filename = os.path.normcase(filename)

            # Show the file contents
            self.code.filename = filename

            # Ensure the file appears on the breakpoint list
            self.breakpoints.insert_filename(filename)

            # Show the breakpoint panel
            self.file_notebook.select(self.breakpoints_frame)

            # ... select the new filename
            self.breakpoints.selection_set(filename)

            # .. and clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    def cmd_bugjar_page(self):
        "Show the Bugjar project page"
        webbrowser.open_new('http://pybee.org/bugjar')

    def cmd_bugjar_github(self):
        "Show the Bugjar GitHub repo"
        webbrowser.open_new('http://github.com/pybee/bugjar')

    def cmd_bugjar_docs(self):
        "Show the Bugjar documentation"
        # If this is a formal release, show the docs for that
        # version. otherwise, just show the head docs.
        if len(NUM_VERSION) == 3:
            webbrowser.open_new('http://bugjar.readthedocs.org/en/v%s/' %
                                VERSION)
        else:
            webbrowser.open_new('http://bugjar.readthedocs.org/')

    def cmd_beeware_page(self):
        "Show the BeeWare project page"
        webbrowser.open_new('http://pybee.org/')

    ######################################################
    # Handlers for GUI actions
    ######################################################

    def on_stack_frame_selected(self, event):
        "When a stack frame is selected, highlight the file and line"
        if event.widget.selection():
            _, index = event.widget.selection()[0].split(':')
            line, frame = self.debugger.stack[int(index)]

            # Display the file in the code view
            self.show_file(filename=frame['filename'], line=line)

            # Display the contents of the selected frame in the inspector
            self.inspector.show_frame(frame)

            # Clear any currently selected item on the breakpoint tree
            self.breakpoints.selection_remove(self.breakpoints.selection())

    def on_breakpoint_selected(self, event):
        "When a breakpoint on the tree has been selected, show the breakpoint"
        if event.widget.selection():
            parts = event.widget.focus().split(':')
            bp = self.debugger.breakpoint((parts[0], int(parts[1])))
            self.show_file(filename=bp.filename, line=bp.line)

            # Clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    def on_breakpoint_file_selected(self, event):
        "When a file is selected on the breakpoint tree, show the file"
        if event.widget.selection():
            filename = event.widget.focus()
            self.show_file(filename=filename)

            # Clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    def on_breakpoint_double_clicked(self, event):
        "When a breakpoint on the tree is double clicked, toggle it's status"
        if event.widget.selection():
            parts = event.widget.focus().split(':')
            bp = self.debugger.breakpoint((parts[0], int(parts[1])))
            if bp.enabled:
                self.debugger.disable_breakpoint(bp)
            else:
                self.debugger.enable_breakpoint(bp)

            # Clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    ######################################################
    # Handlers for debugger responses
    ######################################################

    def on_stack(self, stack):
        "A report of a new stack"
        # Make sure the stack frame list is displayed
        self.file_notebook.select(self.stack_frame)

        # Update the stack list
        self.stack.update_stack(stack)

        if len(stack) > 0:
            # Update the display of the current file
            line = stack[-1][0]
            filename = stack[-1][1]['filename']
            self.show_file(filename=filename, line=line)

            # Select the current stack frame in the frame list
            self.stack.selection_set('frame:%s' % (len(stack) - 1))
        else:
            # No current frame (probably end of execution),
            # so clear the current line marker
            self.code.line = None

    def on_line(self, filename, line):
        "A single line of code has been executed"
        self.run_status.set('Line (%s:%s)' % (filename, line))

    def on_call(self, args):
        "A callable has been invoked"
        self.run_status.set('Call: %s' % args)

    def on_return(self, retval):
        "A callable has returned"
        self.run_status.set('Return: %s' % retval)

    def on_exception(self, name, value):
        "An exception has been raised"
        self.run_status.set('Exception: %s - %s' % (name, value))
        tkMessageBox.showwarning(message='%s: %s' % (name, value))

    def on_postmortem(self):
        "An exception has been raised"
        self.run_status.set('Post mortem mode')
        tkMessageBox.showerror(
            message='Entering post mortem mode. Step/Next will restart')

    def on_restart(self):
        "The code has finished running, and will start again"
        self.run_status.set('Not running')
        tkMessageBox.showinfo(
            message='Program has finished, and will restart.')

    def on_info(self, message):
        "The debugger needs to inform the user of something"
        tkMessageBox.showinfo(message=message)

    def on_warning(self, message):
        "The debugger needs to warn the user of something"
        tkMessageBox.showwarning(message=message)

    def on_error(self, message):
        "The debugger needs to report an error"
        tkMessageBox.showerror(message=message)

    def on_breakpoint_enable(self, bp):
        "A breakpoint has been enabled in the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.enable_breakpoint(bp.line, temporary=bp.temporary)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)

    def on_breakpoint_disable(self, bp):
        "A breakpoint has been disabled in the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.disable_breakpoint(bp.line)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)

    def on_breakpoint_ignore(self, bp, count):
        "A breakpoint has been ignored by the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.ignore_breakpoint(bp.line)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)

    def on_breakpoint_clear(self, bp):
        "A breakpoint has been cleared in the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.clear_breakpoint(bp.line)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)
예제 #44
0
파일: layout.py 프로젝트: farmborst/pytswa
def cs_tabbar(root, w, h, names):
    nb = Notebook(root, width=w, height=h)
    tabs = [Frame(nb) for i in range(len(names))]  # 5 tabs
    [nb.add(tabs[i], text=name) for i, name in enumerate(names)]
    nb.pack()
    return tabs
예제 #45
0
        def __init__(self, parent, controller):
                Frame.__init__(self, parent)

		lupa = PhotoImage(file='img/lupa.png')
		
		#VARIABLES
		tcontrato = ['Vivienda', 'Comercial']
		aplica = StringVar()
		
		#WIDGETS
		
		#========================= HEADER ===========================
		
		self.header = Label(self, text="RECIBO DE CAJA", font="bold")
		self.header.pack(pady=20, side=TOP)
		
		#========================== WRAPPER ==========================
		
		self.wrapper = Frame (self)
		self.wrapper.pack(side=TOP, fill=Y)
		#self.wrapper.pack(side=LEFT, fill=Y)#Este ubica el forma a la IZA
		
		#================ NOTEBOOK =============>
		
		self.nb = Notebook(self.wrapper)
		
		#-----------------------> TAB 1
		
		self.tab1 = Frame (self.nb)
		self.tab1.pack()
		
		self.f0 = Frame(self.tab1)#-------------------------------------
		self.f0.pack(pady=5,fill=X)

		self.R1 = Radiobutton(self.f0, text="Arrendatario", variable=aplica, value='Arrendatario')
		self.R1.pack(padx=20,side=LEFT)
		self.R2 = Radiobutton (self.f0, text="Propietario", variable=aplica, value='Propietario')
		self.R2.pack(padx=20,side=LEFT)
		self.R3 = Radiobutton (self.f0, text="Tercero", variable=aplica, value='Tercero')
		self.R3.pack(padx=20,side=LEFT)
		
		self.f1 = Frame(self.tab1)#-------------------------------------
		self.f1.pack(pady=5,fill=X)
		
		self.cc = Label(self.f1, text='CC/Nit: ')
		self.cc.pack(side=LEFT)
		self.ccE = Entry(self.f1)
		self.ccE.pack(side=LEFT)
		
		self.b1 = Button(self.f1, text='Buscar', image=lupa)
		self.b1.image=lupa
		self.b1.pack(side=LEFT)

		self.f2 = Frame(self.tab1)
		self.f2.pack(pady=5,fill=X)#------------------------------------
		
		self.nombre = Label(self.f2, text='Nombre:')
		self.nombre.pack(side=LEFT)
		self.nombrE = Entry(self.f2, width=5, state=DISABLED)
		self.nombrE.pack(side=LEFT, fill=X, expand=1)
		
		self.f3 = Frame(self.tab1)
		self.f3.pack(pady=5,fill=X)#------------------------------------
		
		self.inmueble = Label(self.f3, text='Inmueble:')
		self.inmueble.pack(side=LEFT)
		
		self.inmuebleCbx = Combobox(self.f3, values=NONE, width=10)
		self.inmuebleCbx.set('')
		self.inmuebleCbx.pack(side=LEFT, fill=X, expand=1)
		
		self.b2 = Button(self.f3, text='Agregar', image=lupa)
		self.b2.image=lupa
		self.b2.pack(side=LEFT)
		
		self.f4 = Frame(self.tab1)
		self.f4.pack(pady=5,fill=X)#------------------------------------
		
		self.fpago = Label(self.f4, text='Forma de Pago:')
		self.fpago.pack(side=LEFT)
		
		self.fpagoCbx = Combobox(self.f4, values=NONE, width=10)
		self.fpagoCbx.set('')
		self.fpagoCbx.pack(side=LEFT)
		
		self.b3 = Button(self.f4, text='Crear novedad', state=DISABLED)
		self.b3.pack(side=LEFT)

		#========================== TREEVIEW ===========================
		
		self.f5 = Frame(self.tab1)
		self.f5.pack(pady=5,fill=X)#------------------------------------
		
		self.tree = Treeview(self.f5, height=4, show="headings", columns=('col1','col2','col3'))
		self.tree.pack(side=LEFT, fill=X, expand=1)
		self.tree.column('col1', width=20, anchor='center')
		self.tree.column('col2', width=200, anchor='center')
		self.tree.column('col3', width=10, anchor='center')
		
		self.tree.heading('col1', text='CC')
		self.tree.heading('col2', text='Descripción')
		self.tree.heading('col3', text='Valor')
		
		self.scroll = Scrollbar(self.f3,orient=VERTICAL,command=self.tree.yview)
		self.tree.configure(yscrollcommand=self.scroll.set)

		self.f6 = Frame(self.tab1)
		self.f6.pack(pady=5,fill=X)#--------------------

		self.notesL = Label(self.f6, text='Observaciones:')
		self.notesL.pack(side=LEFT)

		self.f7 = Frame(self.tab1)
		self.f7.pack(pady=5,fill=X)#-------------------

		self.notesT = Text(self.f7, height=5)
		self.notesT.pack(fill=X, side=LEFT, expand=1)
		
		#-----------------------> TAB 2
		
		self.tab2 = Frame (self.nb)
		self.tab2.pack()
		
		#-----------------------> TAB 3
		
		self.tab3 = Frame (self.nb)
		self.tab3.pack()
	
		#---------------------------------------------------------------
		
		self.nb.add (self.tab1, text="Datos Generales")
		self.nb.add(self.tab2, text="Referencia de Pago", state=DISABLED)
		self.nb.add(self.tab3, text="Referencias Bancarias", state=DISABLED)
		
		self.nb.pack()
		
		#---------------------------------------------------------------
		
		self.fBtn = Frame(self.wrapper)
		self.fBtn.pack()#-------------------------------
	
		self.queryB = Button(self.fBtn, text='Consultar')
		self.queryB.pack(side=RIGHT)
		self.deleteB = Button(self.fBtn, text='Borrar')
		self.deleteB.pack(side=RIGHT)
		self.updateB = Button(self.fBtn, text='Actualizar')
		self.updateB.pack(side=RIGHT)
		self.addB = Button(self.fBtn, text='Agregar')
		self.addB.pack(side=RIGHT)
		
		#========================= ASIDE ===========================
		"""
예제 #46
0
    def __init__(self, root):
        # 数据载入和分类器训练
        bc_dataset = BreastCancerDataSet()
        bc_x_train = bc_dataset.x_train
        bc_y_train = bc_dataset.y_train
        bc_x_test = bc_dataset.x_test
        bc_y_test = bc_dataset.y_test

        ctg_dataset = CardiotocographyDataSet()
        ctg_x_train = ctg_dataset.x_train
        ctg_y_train = ctg_dataset.y_train
        ctg_x_test = ctg_dataset.x_test
        ctg_y_test = ctg_dataset.y_test

        # 初始化UI
        menubar = Tk.Menu(root)  # 添加菜单
        root.config(menu=menubar)
        filemenu = Tk.Menu(menubar)
        filemenu.add_command(label="Exit", command=sys.exit)
        menubar.add_cascade(label="File", menu=filemenu)

        notebook = Notebook(root)  # 添加标签页
        notebook.pack(fill=Tk.BOTH)

        page_0 = Tk.Frame(notebook)
        notebook.add(page_0, text="Main  ")
        notebook_0 = Notebook(page_0)  # 添加子标签页
        notebook_0.pack(fill=Tk.BOTH)
        page_01 = Tk.Frame(notebook_0)
        notebook_0.add(page_01, text="Breast Cancer")
        page_02 = Tk.Frame(notebook_0)
        notebook_0.add(page_02, text="Cardiotocography")
        page_05 = Tk.Frame(notebook_0)
        notebook_0.add(page_05, text="Cardiotocography Features Rank")
        page_04 = Tk.Frame(notebook_0)
        notebook_0.add(page_04, text="Cardiotocography Features Corr")
        page_03 = Tk.Frame(notebook_0)
        notebook_0.add(page_03, text="Cardiotocography Features Pair")
        page_06 = Tk.Frame(notebook_0)
        notebook_0.add(page_06, text="Console Output")

        page_1 = Tk.Frame(notebook)
        notebook.add(page_1, text="Training  ")
        notebook_1 = Notebook(page_1)  # 添加子标签页
        notebook_1.pack(fill=Tk.BOTH)
        page_11 = Tk.Frame(notebook_1)
        notebook_1.add(page_11, text="LR")
        page_12 = Tk.Frame(notebook_1)
        notebook_1.add(page_12, text="SVM")
        page_13 = Tk.Frame(notebook_1)
        notebook_1.add(page_13, text="RF")

        page_2 = Tk.Frame(notebook)
        notebook.add(page_2, text="Testing  ")
        subnotebook_2 = Notebook(page_2)  # 添加子标签页
        subnotebook_2.pack(fill=Tk.BOTH)
        page_21 = Tk.Frame(subnotebook_2)
        subnotebook_2.add(page_21, text="LR")
        page_22 = Tk.Frame(subnotebook_2)
        subnotebook_2.add(page_22, text="SVM")
        page_23 = Tk.Frame(subnotebook_2)
        subnotebook_2.add(page_23, text="RF")

        page_3 = Tk.Frame(notebook)
        notebook.add(page_3, text="Learning Curve")

        page_4 = Tk.Frame(notebook)
        notebook.add(page_4, text="Validation Curve")

        page_5 = Tk.Frame(notebook)
        notebook.add(page_5, text="ROC & AUC")

        page_6 = Tk.Frame(notebook)
        notebook.add(page_6, text="GridSearchCV")

        page_7 = Tk.Frame(notebook)
        notebook.add(page_7, text="t-SNE")

        # 第0页 主页

        console = ConsoleFrame(page_06)
        console.pack(fill=Tk.BOTH)

        bc_eva = Evaluator(scaler=StandardScaler(), pca=PCA(n_components=2), clf=SVC(probability=True, random_state=1))
        BreastCancerMainFrame(page_01, bc_x_train, bc_y_train, bc_x_test, bc_y_test, bc_eva, console).pack(fill=Tk.BOTH)

        ctg_eva = Evaluator(scaler=StandardScaler(), pca=PCA(n_components=2), clf=SVC(probability=True, random_state=1))
        CardiotocographyMainFrame(page_02, ctg_x_train, ctg_y_train, ctg_x_test, ctg_y_test, ctg_eva, console).pack(fill=Tk.BOTH)

        FeaturesPairFrame(page_03, ctg_x_train, ctg_y_train, ctg_x_test, ctg_y_test, ctg_eva, ctg_dataset.df, console).pack(
            fill=Tk.BOTH)

        FeaturesCorrFrame(page_04, ctg_x_train, ctg_y_train, ctg_x_test, ctg_y_test, ctg_eva, ctg_dataset.df, console).pack(
            fill=Tk.BOTH)

        FeaturesRankFrame(page_05, ctg_x_train, ctg_y_train, ctg_x_test, ctg_y_test, ctg_eva, ctg_dataset.df, console).pack(
            fill=Tk.BOTH)
예제 #47
0
class Application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.FileObjects = []
        self.FileObjectNames = []
        self.intSettings = {'Group': IntVar(value=1),
                            'DataObject': IntVar(value=1),
                            'FieldVariables': IntVar(value=1)}

        self.FieldVariables = OrderedDict()

        self.notebook = Notebook(self)
        self.tab1 = Frame(self.notebook)
        self.tab2 = Frame(self.notebook)
        self.notebook.add(self.tab1, text="Data Interaction")
        self.notebook.add(self.tab2, text="Mach-1 Image Grid")
        self.notebook.grid(row=0, column=0, sticky=NW)

        #####  BEGIN TAB 1 #####
        self.frameDataFiles = Frame(self.tab1)
        self.frameDataFiles.grid(row=0, column=0, sticky=N+W+E)
        self.buttonLoadFile = Button(self.frameDataFiles, text="Load Data File",
                                     command=self.loadFile)
        self.buttonLoadFile.grid(row=0, column=0, padx=1, pady=1,
                                 sticky=N+W+E)
        self.buttonRemoveFile = Button(self.frameDataFiles, text="Remove Selected File",
                                       command=self.removeDataObject)
        self.buttonRemoveFile.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)
        self.frameDataObjects = LabelFrame(self.tab1, text="Data Files")
        self.frameDataObjects.grid(row=0, column=1, padx=1, pady=1, sticky=N+W+E)

        self.frameGroups = LabelFrame(self.tab1, text="Group Selection")
        self.frameGroups.grid(row=1, column=0, padx=1, pady=1,
                              sticky=N+W+E )
        Label(self.frameGroups, text="").grid(row=0, column=0, sticky=N+W+E)
        self.frameChannels = LabelFrame(self.tab1, text="Channel Selection")
        self.frameChannels.grid(row=1, column=1, padx=1, pady=1,
                                sticky=N+W+E)
        Label(self.frameChannels, text="").grid(row=0, column=0, sticky=N+W+E)

        self.frameTab1BottomLeft = Frame(self.tab1)
        self.frameTab1BottomLeft.grid(row=2, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonSaveFile = Button(self.frameTab1BottomLeft, text="Save Selected to Pickle",
                                     command=self.saveFile)
        self.buttonSaveFile.grid(row=0, column=0, padx=1, pady=1,
                                 sticky=N+W+E)

        self.buttonSaveCSV = Button(self.frameTab1BottomLeft, text="Save Selected to CSV",
                                    command=self.saveCSV)
        self.buttonSaveCSV.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)

        self.buttonGetThickness = Button(self.frameTab1BottomLeft, text="Get Mach-1 Thicknesses",
                                         command=self.findThicknesses)
        self.buttonGetThickness.grid(row=2, column=0, padx=1, pady=1, sticky=N+W+E)

        self.buttonPlot = Button(self.frameTab1BottomLeft, text="Plot Selected Channels",
                                 command=self.plotChannels)
        self.buttonPlot.grid(row=3, column=0, padx=1, pady=1,
                             sticky=N+W+E)

        self.frameTab1BottomRight = Frame(self.tab1)
        self.frameTab1BottomRight.grid(row=2, column=1, padx=1, pady=1, sticky=N+W+E)
        self.buttonMovingAvg = Button(self.frameTab1BottomRight, text="Apply Moving Average",
                                      command=self.applyMovingAvg)
        self.buttonMovingAvg.grid(row=0, column=0, padx=1, pady=1, columnspan=2,
                                  sticky=N+W+E)
        self.windowSize = IntVar(value=10)
        Label(self.frameTab1BottomRight, text="Window Size").grid(row=1, column=0, padx=1, pady=1,
                                                                  sticky=N+W)
        Entry(self.frameTab1BottomRight, textvariable=self.windowSize, width=4).grid(row=1, column=1, padx=1,
                                                                                     pady=1, sticky=N+W)
        #####  END TAB 1 #####

        ##### BEGIN TAB 2 #####
        self.frameImageButtons = Frame(self.tab2)
        self.frameImageButtons.grid(row=0, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonLoadImage = Button(self.frameImageButtons, text="Load Image",
                                      command=self.loadImage)
        self.buttonLoadImage.grid(row=0, column=0, padx=1, pady=1, sticky=N+W+E)

        self.buttonLoadMapFile = Button(self.frameImageButtons, text="Load Mach-1 Site Locations",
                                        command=self.loadMachMap)

        self.buttonLoadMapFile.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonDefineMask = Button(self.frameImageButtons, text="Define Mask",
                                       command=self.cropImage)
        self.buttonDefineMask.grid(row=2, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonClearMask = Button(self.frameImageButtons, text="Clear Mask",
                                      command=self.clearMask)
        self.buttonClearMask.grid(row=3, column=0, padx=1, pady=1, sticky=N+W+E)

        self.frameFieldVariables = LabelFrame(self.tab2, text="Field Variables")
        self.frameFieldVariables.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)

        ##### END TAB 2 #####
        self.grid()

    def loadFile(self):
        self.filename = tkFileDialog.askopenfilename(
            parent=root,
            initialdir=os.getcwd(),
            title="Select a Data File.")
        if self.filename:
            self.FileObjects.append(Data(self.filename))
            self.FileObjectNames.append(os.path.basename(self.filename))
            for child in self.frameGroups.grid_slaves():
                child.grid_remove()
                del child
            self.intSettings["Group"].set(1)
            row = 0
            column = 0
            for i, g in enumerate(self.FileObjects[-1].groups):
                if i % 12 == 0:
                    row = 0
                    column += 1
                Radiobutton(self.frameGroups,
                            text=g,
                            indicatoron=0,
                            width=5,
                            variable=self.intSettings["Group"],
                            command=self.populateChannelList,
                            value=i+1).grid(row=row, column=column, sticky=NW)
                row += 1
            g = self.FileObjects[-1].groups[self.intSettings["Group"].get() - 1]
            for child in self.frameChannels.grid_slaves():
                child.grid_remove()
                del child
            row = 0
            column = 0
            self.channelSelections = {}
            for c in self.FileObjects[-1].time[g].keys():
                if i % 12 == 0:
                    row = 0
                    column += 1
                self.channelSelections[c] = IntVar(value=0)
                Checkbutton(self.frameChannels,
                            text=c,
                            variable=self.channelSelections[c]).grid(row=row, column=column, sticky=NW)
                row += 1
            counter = len(self.frameDataObjects.grid_slaves()) + 1
            Radiobutton(self.frameDataObjects,
                        text=self.FileObjectNames[-1],
                        indicatoron=0,
                        variable=self.intSettings["DataObject"],
                        command=self.selectDataObject,
                        value=counter).grid(row=counter, column=0, sticky=N+E+W)

    def selectDataObject(self):
        for child in self.frameGroups.grid_slaves():
            child.grid_remove()
            del child
        self.intSettings["Group"].set(1)
        row = 0
        column = 0
        for i, g in enumerate(self.FileObjects[self.intSettings["DataObject"].get()-1].groups):
            if i % 12 == 0:
                row = 0
                column += 1
            Radiobutton(self.frameGroups,
                        text=g,
                        indicatoron=0,
                        width=5,
                        variable=self.intSettings["Group"],
                        command=self.populateChannelList,
                        value=i+1).grid(row=row, column=column, sticky=NW)
            row += 1
        g = self.FileObjects[self.intSettings["DataObject"].get()-1].groups[self.intSettings["Group"].get() - 1]
        for child in self.frameChannels.grid_slaves():
            child.grid_remove()
            del child
        row = 0
        column = 0
        self.channelSelections = {}
        for c in self.FileObjects[self.intSettings["DataObject"].get()-1].time[g].keys():
            if i % 12 == 0:
                row = 0
                column += 1
            self.channelSelections[c] = IntVar(value=0)
            Checkbutton(self.frameChannels,
                        text=c,
                        variable=self.channelSelections[c]).grid(row=row, column=column, sticky=NW)
            row += 1

    def removeDataObject(self):
        if tkMessageBox.askyesno(message="Really remove the selected data?"):
            del self.FileObjects[self.intSettings["DataObject"].get()-1]
            del self.FileObjectNames[self.intSettings["DataObject"].get()-1]
            for child in self.frameDataObjects.grid_slaves():
                child.grid_remove()
                del child
            for i, o in enumerate(self.FileObjects):
                Radiobutton(self.frameDataObjects,
                            text=self.FileObjectNames[i],
                            indicatoron=0,
                            variable=self.intSettings["DataObject"],
                            command=self.selectDataObject,
                            value=i+1).grid(row=i, column=0, sticky=N+E+W)
            if len(self.FileObjects) > 0:
                self.intSettings["DataObject"].set(1)
            else:
                for child in self.frameGroups.grid_slaves():
                    child.grid_remove()
                    del child
                for child in self.frameChannels.grid_slaves():
                    child.grid_remove()
                    del child


    def makePlot(self, group, keys):
        f = Figure()
        self.axes = []
        if type(keys) is list:
            n = len(keys)
            for i, k in enumerate(keys):
                if i == 0:
                    self.axes.append(f.add_subplot(n, 1, i + 1))
                else:
                    self.axes.append(f.add_subplot(n, 1, i + 1,
                                                   sharex=self.axes[0]))
                self.axes[i].plot(self.FileObjects[self.intSettings["DataObject"].get()-1].time[group][k],
                                  self.FileObjects[self.intSettings["DataObject"].get()-1].data[group][k])
                if self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses and k == "Fz, N":
                    try:
                        self.axes[i].axvline(x=self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses[group][1][0], color='r')
                        self.axes[i].axvline(x=self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses[group][1][1], color='g')
                    except:
                        pass
                self.axes[i].set_ylabel(k)
        else:
            self.axes.append(f.add_subplot(1,1,1))
            self.axes[0].plot(self.FileObjects[self.intSettings["DataObject"].get()-1].time[group][keys],
                              self.FileObjects[self.intSettings["DataObject"].get()-1].data[group][keys])
            if self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses and k == "Fz, N":
                self.axes[i].axvline(l=self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses[group][1][0], color='r')
                self.axes[i].axvline(l=self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses[group][1][1], color='g')
            self.axes[0].set_ylabel(keys)
        self.axes[-1].set_xlabel("Time (s)")
        canvas_frame = Frame(self.tab1)
        canvas_frame.grid(row=0, column=2, rowspan=4, sticky=N+W+E+S)
        canvas = FigureCanvasTkAgg(f, master=canvas_frame)
        canvas.draw()
        canvas.get_tk_widget().grid(row=0, column=0,
                                    padx=1, pady=1, sticky=N+W+E+S)

        toolbar_frame = Frame(self.tab1)
        toolbar_frame.grid(row=4, column=2, sticky=NW)
        toolbar = NavigationToolbar2TkAgg(canvas, toolbar_frame)
        toolbar.update()

        Button(self.tab1, text="Crop", command=self.cropData).grid(
            row=4, column=2, sticky=NE)

    def findThicknesses(self):
        self.FieldVariables["Thicknesses"] = []
        for i, g in enumerate(self.FileObjects[self.intSettings["DataObject"].get()-1].groups):
            self.FileObjects[self.intSettings["DataObject"].get()-1].getThicknessMach1(g)
            self.FieldVariables["Thicknesses"].append(self.FileObjects[self.intSettings["DataObject"].get()-1].thicknesses[g][0])
        self.populateFieldVariableList()

    def cropData(self):
        group = self.FileObjects[self.intSettings["DataObject"].get()-1].groups[self.intSettings["Group"].get() - 1]
        (start, end) = self.axes[0].xaxis.get_view_interval()
        for c in self.channelSelections.keys():
            if self.channelSelections[c].get():
                self.FileObjects[self.intSettings["DataObject"].get()-1].windowData(group, c, start, end)
        self.populateChannelList()

    def populateChannelList(self):
        g = self.FileObjects[self.intSettings["DataObject"].get()-1].groups[self.intSettings["Group"].get() - 1]
        self.channelSelections = {}
        for child in self.frameChannels.grid_slaves():
            child.grid_remove()
            del child
        row = 0
        column = 0
        for i, c in enumerate(self.FileObjects[self.intSettings["DataObject"].get()-1].time[g].keys()):
            if i % 12 == 0:
                row = 0
                column += 1
            self.channelSelections[c] = IntVar(value=0)
            Checkbutton(self.frameChannels,
                        text=c,
                        variable=self.channelSelections[c]).grid(row=row, column=column, sticky=NW)
            row += 1

    def plotChannels(self):
        keys = []
        for c in self.channelSelections.keys():
            if self.channelSelections[c].get():
                keys.append(c)

        self.makePlot(
            self.FileObjects[self.intSettings["DataObject"].get()-1].groups[self.intSettings["Group"].get() - 1],
            keys)

    def applyMovingAvg(self):
        group = self.FileObjects[self.intSettings["DataObject"].get()-1].groups[
            self.intSettings["Group"].get() - 1]
        for c in self.channelSelections.keys():
            if self.channelSelections[c].get():
                self.FileObjects[self.intSettings["DataObject"].get()-1].movingAverage(
                    group, c, win=self.windowSize.get())
        self.populateChannelList()

    def saveFile(self):
        group = self.FileObjects[self.intSettings["DataObject"].get()-1].groups[self.intSettings["Group"].get() - 1]
        for c in self.channelSelections.keys():
            if self.channelSelections[c].get():
                fid = open(os.path.abspath(string.replace(
                    self.filename, ".tdms", "_{:s}_{:s}.pkl".format(group, c))), "wb")
                pickle.dump((self.FileObjects[self.intSettings["DataObject"].get()-1].time[group][c], self.FileObjects[self.intSettings["DataObject"].get()-1].data[group][c]),
                            fid, 2)
                fid.close()

    def saveCSV(self):
        group = self.FileObjects[self.intSettings["DataObject"].get()-1].groups[self.intSettings["Group"].get() - 1]
        for c in self.channelSelections.keys():
            if self.channelSelections[c].get():
                if self.filename.lower().endswith(".tdms"):
                    oname = string.replace(self.filename, ".tdms", "_{:s}_{:s}.csv".format(group, c))
                    oname = string.replace(oname, " ", "_")
                    fid = open(os.path.abspath(oname), "wt")
                elif self.filename.lower().endswith(".txt"):
                    oname = string.replace(self.filename, ".txt", "_{:s}_{:s}.csv".format(group, c))
                    oname = string.replace(oname, " ", "_")
                    fid = open(os.path.abspath(oname), "wt")
                fid.write("Time, {:s}\n".format(c))
                for (t, v) in zip(
                        self.FileObjects[self.intSettings["DataObject"].get()-1].time[group][c], self.FileObjects[self.intSettings["DataObject"].get()-1].data[group][c]):
                    fid.write("{:12.6f}, {:12.6f}\n".format(t, v))
                fid.close()

    def loadImage(self):
        self.imagefile = tkFileDialog.askopenfilename(
            parent=root,
            initialdir=os.getcwd(),
            filetypes=[('image files', '.jpg .jpeg .png .tif .tiff')],
            title="Select a Image.")
        if not self.imagefile:
            print("A file was not selected")
            return
        self.image = imread(self.imagefile)
        self.cropimage=False
        self.plotImage()

    def loadMachMap(self):
        self.mapfile = tkFileDialog.askopenfilename(
            parent=root,
            initialdir=os.getcwd(),
            filetypes=[('Mach-1 map files', '.map')],
            title="Select the Mach-1 map file")
        if not self.mapfile:
            print("A file was not selected")
            return
        self.FileObjects[self.intSettings["DataObject"].get()-1].readMach1PositionMap(self.mapfile)
        self.maskFromMap()
        self.getTestLocations()

    def maskFromMap(self):
        ind = self.intSettings["DataObject"].get()-1
        self.polygons = []
        for p in self.FileObjects[ind].MachPositions["SubSurfaceID"].unique():
            points = self.FileObjects[ind].MachPositions.query('(SubSurfaceID == "{:s}") & (PointType == 1)'.format(p))[["PixelX", "PixelY"]]
            points = np.array(points)
            points = np.vstack((points, points[0,:]))
            self.polygons.append(points)
            self.UpdateMask()

    def getTestLocations(self):
        ind = self.intSettings["DataObject"].get()-1
        self.TestLocations = np.array(self.FileObjects[ind].MachPositions.query("(PointType == 0)")[["PixelX", "PixelY"]], dtype=float)

    def cropImage(self):
        self.points = []
        self.polygons = []
        self.image_canvas.get_tk_widget().bind("<Button-1>", self.XY_handler)
        self.image_canvas.get_tk_widget().bind("<Button-3>", self.nextPolygon)
        self.image_canvas.get_tk_widget().bind("<Return>", self.UpdateMask)
        #self.image_canvas.get_tk_widget().grid(row=0, column=0, padx=1, pady=1, sticky=N+E+W+S)
        self.image_canvas.draw()

    def XY_handler(self, aHandledEVENT):
        self.points.append((aHandledEVENT.x*self.screen2index, aHandledEVENT.y*self.screen2index))
        if len(self.points) > 1:
            self.addLine()

    def addLine(self):
        codes = [Path.MOVETO] + [Path.LINETO] * (len(self.points) - 1)
        path = Path(tuple(self.points), codes)
        patch = patches.PathPatch(path, lw=2)
        self.image_ax.add_patch(patch)
        self.image_canvas.draw()

    def nextPolygon(self, aHandledEVENT):
        tmp = np.copy(self.points)
        tmp = np.vstack((tmp, tmp[0,:]))
        self.polygons.append(tmp)
        self.points = []

    def UpdateMask(self, aHandledEVENT=None):
        img = Image.new('L', (self.image.shape[1], self.image.shape[0]), 1)
        drw = ImageDraw.Draw(img, 'L')
        for p in self.polygons:
            p = p.ravel()
            drw.polygon(tuple(p), outline=1, fill=0)
        self.maskimage = np.array(img, dtype=bool)
        self.cropimage = True
        if aHandledEVENT is None:
            self.image_canvas.get_tk_widget().unbind("<Button-1>")
            self.image_canvas.get_tk_widget().unbind("<Button-3>")
            self.image_canvas.get_tk_widget().unbind("<Return>")
        self.plotImage()

    def clearMask(self):
        self.cropimage = False
        self.plotImage()

    def populateFieldVariableList(self):
        for child in self.frameFieldVariables.grid_slaves():
            child.grid_remove()
            del child
        for i, (k, v) in enumerate(self.FieldVariables.items()):
            Radiobutton(self.frameFieldVariables,
                        text=k,
                        indicatoron=0,
                        variable=self.intSettings["FieldVariables"],
                        value=i+1).grid(row=i, column=0, sticky=N+E+W)
        try:
            self.buttonPlotOverlay
        except:
            self.buttonPlotOverlay = Button(self.frameImageButtons,
                                            text="Plot Selected",
                                            command=self.overlayData)
            self.buttonPlotOverlay.grid(row=4, column=0, sticky=N+W+E)

    def plotImage(self, data=None):
        try:
            self.image
        except:
            return
        self.imageFrame = Frame(self.tab2)
        self.image_width_inches = 6.0
        self.imageFrame.grid(row=0, column=1, padx=1, pady=1, sticky=N+E+W+S)
        self.image_aspect = float(self.image.shape[1])/float(self.image.shape[0])
        self.image_dpi = 96
        self.screen2index = self.image.shape[1] / (self.image_width_inches * self.image_dpi)
        self.image_fig = Figure((self.image_width_inches, self.image_width_inches/self.image_aspect), dpi=self.image_dpi, frameon=False)
        self.image_ax = self.image_fig.add_axes([0.0, 0.0, 1.0, 1.0,])
        self.image_ax.imshow(self.image)
        self.image_ax.get_xaxis().set_visible(False)
        self.image_ax.get_yaxis().set_visible(False)
        self.image_ax.grid(False)

        self.image_canvas = FigureCanvasTkAgg(self.image_fig, master=self.imageFrame)
        self.image_canvas.get_tk_widget().grid(row=0, column=0, padx=1, pady=1, sticky=N+E+W+S)
        self.image_canvas.get_tk_widget().config(width=self.image_width_inches*self.image_dpi,
                                                 height=self.image_width_inches*self.image_dpi/self.image_aspect)
        self.image_toolbar_frame = Frame(self.tab2)
        self.image_toolbar_frame.grid(row=1, column=1, sticky=NW)
        self.image_toolbar = NavigationToolbar2TkAgg(self.image_canvas, self.image_toolbar_frame)
        self.image_toolbar.update()
        self.image_canvas.draw()

    def overlayData(self):
        self.image_ax.hold(True)
        grid_size = self.image.shape[0:2]
        gridx, gridy = np.mgrid[0:grid_size[0], 0:grid_size[1]]
        key = self.FieldVariables.keys()[self.intSettings["FieldVariables"].get() - 1] 
        data = np.array(self.FieldVariables[key][-self.TestLocations.shape[0]:])
        m, se = np.mean(data), sem(data)
        h = se * t.ppf(0.975, data.size - 1)
        #rbf = Rbf(self.TestLocations[:,0], self.TestLocations[:,1], data, epsilon=2)
        #gridz = rbf(gridx, gridy)
        gridz = griddata(self.TestLocations[:, [1, 0]], data, (gridx, gridy), 'nearest')
        if self.cropimage:
            gridz = ma.masked_where(self.maskimage, gridz, copy=False)
            #gridz = ma.masked_where(np.abs((gridz - med))/mdev > 7.0, gridz, copy=False) 
        cmap = sns.cubehelix_palette(light=1, as_cmap=True)
        im = self.image_ax.imshow(gridz, cmap=cmap, alpha=0.75,
                                  norm=colors.Normalize(vmin=data.min(), vmax=m+h, clip=False))

        self.image_fig.colorbar(im, shrink=0.75) 
        self.image_ax.scatter(self.TestLocations[:,0], self.TestLocations[:,1])
        text = [str(i+1) for i in xrange(self.TestLocations.shape[0])]
        for i, tt in enumerate(text):
            self.image_ax.text(self.TestLocations[i,0] + 10, self.TestLocations[i,1] - 10, tt, color="orange", size=8)
        self.image_canvas.draw()
예제 #48
0
    def __init__(self, master):
        
	self.fname="" 
        #global variables
        self.t1=StringVar()
        self.t2=StringVar()
        self.t3=StringVar()
        self.t4=StringVar()
        self.t5=StringVar()
        self.t6=StringVar()
        self.t7=StringVar()
        self.t8=StringVar()
        self.t9=StringVar()
        self.t10=StringVar()
        self.t11=StringVar()
        self.t12=StringVar()
        
        self.var1=StringVar()
        self.var2=StringVar()
        self.var3=StringVar()
        self.var4=StringVar()
        self.var5=StringVar()
        self.var6=StringVar()
        self.var7=StringVar()
        self.var8=StringVar()
        self.var9=StringVar()
        self.var10=StringVar()
        self.var11=StringVar()
        self.var12=StringVar()
        #end
        
        mymaster = Frame(master, name='mymaster') # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window    
        #master.minsize(width=900, height=900)
        #master.maxsize(width=800, height=600)
        #end
        
        #title of window
        master.title("Airtun-ng")
        #end
        
        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont=tkFont.Font(family="Helvetica", size=15,underline = True)
        self.myfontnew=tkFont.Font(family="Helvetica", size=11,underline = True)
        #end
        
        
       
        nb = Notebook(mymaster, name='nb') # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3) # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1") # add tab to Notebook
    
        # repeat for each tab
        self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")
        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        
        #End
        
	#frame content 7
	Label(self.frame_content7, text = 'Aigraph-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        btndetect=Button(self.frame_content7, text = 'Detect', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 1, column = 0, padx = 5, pady = 5)
		
	btndbrowse=Button(self.frame_content7, text = 'Attach File', command =self.browse_file, height=2, width=15, font=self.customFont).grid(row = 3, column = 0, padx = 5, pady = 5)	
	self.lilnew1=Listbox(self.frame_content7,bg="black", fg="white", font=self.myfont, selectmode=SINGLE, width=30, height=15)
        self.lilnew1.grid(row = 1, column = 1, rowspan=3)
	#End
	
        Label(self.frame_content, text = 'Airtun-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content, text = 'Options :',font=self.myfontnew, bg="white").grid(row = 1, column = 1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5, text = 'Edit Command From Here',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 0, column = 0)
        TextCommandBox=Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output=Text(self.frame_content5,bg="black", fg="white", font=self.myfont, height=20, width=42)
        self.output.grid(row = 0, column = 1, padx=50, pady=5, rowspan=3)
        btnsubmit=Button(self.frame_content5, width=15, height=2, text="Get Result", command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear=Button(self.frame_content5, width=15, height=2, text="Clear Output", command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "-x", \
                 onvalue = "-x", offvalue ="", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var1)
        self.C1.grid(row = 2, column = 0, padx = 5, pady = 5)
        self.t1=Text(self.frame_content,height=1,width = 20)
        self.t1.grid(row = 2, column = 1, padx = 5, pady = 5)
        l1=Label(self.frame_content, text = ': maximum number of packets per second (optional)',font=self.myfont, bg="white", justify=LEFT).grid(row = 2, column = 2, padx = 5, pady = 5)
        
        self.C2 = Checkbutton(self.frame_content, text = "-a", \
                 onvalue = "-a", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var2)
        self.C2.grid(row = 3, column = 0, padx = 5, pady = 5)
        self.t2=Text(self.frame_content,height=1,width = 20)
        self.t2.grid(row = 3, column = 1, padx = 5, pady = 5)
        l2=Label(self.frame_content, text = ': set Access Point MAC address (mandatory)',font=self.myfont, bg="white", justify=LEFT).grid(row = 3, column = 2, padx = 5, pady = 5)
        
        self.C3 = Checkbutton(self.frame_content, text = "-i", \
                 onvalue = "-i", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row = 4, column = 0, padx = 5, pady = 5)
        self.t3=Text(self.frame_content,height=1,width = 20)
        self.t3.grid(row = 4, column = 1, padx = 5, pady = 5)
        l3=Label(self.frame_content, text = ': capture packets from this interface (optional)',font=self.myfont, bg="white", justify=LEFT).grid(row = 4, column = 2, padx = 5, pady = 5)
        
        self.C4 = Checkbutton(self.frame_content, text = "-y", \
                 onvalue = "-y", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var5)
        self.C4.grid(row = 5, column = 0, padx = 5, pady = 5)
        self.t4=Text(self.frame_content,height=1,width = 20)
        self.t4.grid(row = 5, column = 1, padx = 5, pady = 5)
        l4=Label(self.frame_content, text = ': read PRGA from this file (optional / one of -y or -w must be defined)',font=self.myfont, bg="white", justify=LEFT).grid(row = 5, column = 2, padx = 5, pady = 5)
        
        self.C5 = Checkbutton(self.frame_content, text = "-W", \
                 onvalue = "-W", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var6)
        self.C5.grid(row = 6, column = 0, padx = 5, pady = 5)
        self.t5=Text(self.frame_content,height=1,width = 20)
        self.t5.grid(row = 6, column = 1, padx = 5, pady = 5)
        l5=Label(self.frame_content, text = ': use this WEP-KEY to encrypt packets (optional / one of -y or -w must be defined)',font=self.myfont, bg="white", justify=LEFT).grid(row = 6, column = 2, padx = 5, pady = 5)
        
        self.C6 = Checkbutton(self.frame_content, text = "-t", \
                 onvalue = "-t", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var7)
        self.C6.grid(row = 8, column = 0, padx = 5, pady = 5)
        self.t6=Text(self.frame_content,height=1,width = 20)
        self.t6.grid(row = 8, column = 1, padx = 5, pady = 5)
        l6=Label(self.frame_content, text = ': send frames to AP (1) or to client (0) (optional / defaults to 0)',font=self.myfont, bg="white", justify=LEFT).grid(row = 8, column = 2, padx = 5, pady = 5)
        
        self.C7 = Checkbutton(self.frame_content, text = "-r", \
                 onvalue = "-r", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var8)
        self.C7.grid(row = 9, column = 0, padx = 5, pady = 5)
        self.t7=Text(self.frame_content,height=1,width = 20)
        self.t7.grid(row = 9, column = 1, padx = 5, pady = 5)
        l7=Label(self.frame_content, text = ': read frames out of pcap file (optional)',font=self.myfont, bg="white", justify=LEFT).grid(row = 9, column = 2, padx = 5, pady = 5)
        
        self.C8 = Checkbutton(self.frame_content, text = "-h", \
                 onvalue = "-h", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var9)
        self.C8.grid(row = 10, column = 0, padx = 5, pady = 5)
        self.t8=Text(self.frame_content,height=1,width = 20)
        self.t8.grid(row = 10, column = 1, padx = 5, pady = 5)
        l8=Label(self.frame_content, text = ': source MAC address',font=self.myfont, bg="white", justify=LEFT).grid(row = 10, column = 2, padx = 5, pady = 5)
        
        self.C9 = Checkbutton(self.frame_content, text = "-H", \
                 onvalue = "-H", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var10)
        self.C9.grid(row = 11, column = 0, padx = 5, pady = 5)
        self.t9=Text(self.frame_content,height=1,width = 20)
        self.t9.grid(row = 11, column = 1, padx = 5, pady = 5)
        l9=Label(self.frame_content, text = ': Display help. Long form help',font=self.myfont, bg="white", justify=LEFT).grid(row = 11, column = 2, padx = 5, pady = 5)
        
        Label(self.frame_content, text = 'Repeater Options :',font=self.myfontnew, bg="white").grid(row = 12, column = 1)
        
        self.C10 = Checkbutton(self.frame_content, text = "--repeat", \
                 onvalue = "--repeat", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var11)
        self.C10.grid(row = 13, column = 0, padx = 5, pady = 5)
        self.t10=Text(self.frame_content,height=1,width = 20)
        self.t10.grid(row = 13, column = 1, padx = 5, pady = 5)
        l10=Label(self.frame_content, text = ': activates repeat mode. Short form -f.',font=self.myfont, bg="white", justify=LEFT).grid(row = 13, column = 2, padx = 5, pady = 5)
        
        self.C11 = Checkbutton(self.frame_content, text = "--bssid", \
                 onvalue = "--bssid", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont, variable=self.var12)
        self.C11.grid(row = 14, column = 0, padx = 5, pady = 5)
        self.t11=Text(self.frame_content,height=1,width = 20)
        self.t11.grid(row = 14, column = 1, padx = 5, pady = 5)
        l11=Label(self.frame_content, text = ': BSSID to repeat. Short form -d.',font=self.myfont, bg="white", justify=LEFT).grid(row = 14, column = 2, padx = 5, pady = 5)
        
        self.C12 = Checkbutton(self.frame_content, text = "--netmask", \
                 onvalue = "--netmask", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont)
        self.C12.grid(row = 15, column = 0, padx = 5, pady = 5)
        self.t12=Text(self.frame_content,height=1,width = 20)
        self.t12.grid(row = 15, column = 1, padx = 5, pady = 5)
        l12=Label(self.frame_content, text = ': netmask for BSSID filter. Short form -m.',font=self.myfont, bg="white", justify=LEFT).grid(row = 15, column = 2, padx = 5, pady = 5)
예제 #49
0
파일: view.py 프로젝트: adamchainz/bugjar
class MainWindow(object):
    def __init__(self, root, debugger):
        '''
        -----------------------------------------------------
        | main button toolbar                               |
        -----------------------------------------------------
        |       < ma | in content area >      |             |
        |            |                        |             |
        | File list  | File name              | Inspector   |
        | (stack/    | Code area              |             |
        | breakpnts) |                        |             |
        |            |                        |             |
        |            |                        |             |
        -----------------------------------------------------
        |     status bar area                               |
        -----------------------------------------------------

        '''

        # Obtain and expand the current working directory.
        base_path = os.path.abspath(os.getcwd())
        base_path = os.path.normcase(base_path) + '/'

        # Create a filename normalizer based on the CWD.
        self.filename_normalizer = filename_normalizer(base_path)

        self.debugger = debugger
        # Associate the debugger with this view.
        self.debugger.view = self

        # Root window
        self.root = root
        self.root.title('Bugjar')
        self.root.geometry('1024x768')

        # Prevent the menus from having the empty tearoff entry
        self.root.option_add('*tearOff', False)
        # Catch the close button
        self.root.protocol("WM_DELETE_WINDOW", self.cmd_quit)
        # Catch the "quit" event.
        self.root.createcommand('exit', self.cmd_quit)

        # Setup the menu
        self._setup_menubar()

        # Set up the main content for the window.
        self._setup_button_toolbar()
        self._setup_main_content()
        self._setup_status_bar()

        # Now configure the weights for the root frame
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=0)
        self.root.rowconfigure(1, weight=1)
        self.root.rowconfigure(2, weight=0)

        debugger.start()

    ######################################################
    # Internal GUI layout methods.
    ######################################################

    def _setup_menubar(self):
        # Menubar
        self.menubar = Menu(self.root)

        # self.menu_Apple = Menu(self.menubar, name='Apple')
        # self.menubar.add_cascade(menu=self.menu_Apple)

        self.menu_file = Menu(self.menubar)
        self.menubar.add_cascade(menu=self.menu_file, label='File')

        self.menu_program = Menu(self.menubar)
        self.menubar.add_cascade(menu=self.menu_program, label='Program')

        self.menu_help = Menu(self.menubar)
        self.menubar.add_cascade(menu=self.menu_help, label='Help')

        # self.menu_Apple.add_command(label='Test', command=self.cmd_dummy)

        # self.menu_file.add_command(label='New', command=self.cmd_dummy, accelerator="Command-N")
        self.menu_file.add_command(label='Open...', command=self.cmd_open_file, accelerator="Command-O")
        self.root.bind('<Command-o>', self.cmd_open_file)
        # self.menu_file.add_command(label='Close', command=self.cmd_dummy)

        self.menu_program.add_command(label='Run', command=self.cmd_run, accelerator="R")
        self.root.bind('<r>', self.cmd_run)
        self.menu_program.add_command(label='Step', command=self.cmd_step, accelerator="S")
        self.root.bind('<s>', self.cmd_step)
        self.menu_program.add_command(label='Next', command=self.cmd_next, accelerator="N")
        self.root.bind('<n>', self.cmd_next)
        self.menu_program.add_command(label='Return', command=self.cmd_return, accelerator="BackSpace")
        self.root.bind('<BackSpace>', self.cmd_return)

        self.menu_help.add_command(label='Open Documentation', command=self.cmd_bugjar_docs)
        self.menu_help.add_command(label='Open Bugjar project page', command=self.cmd_bugjar_page)
        self.menu_help.add_command(label='Open Bugjar on GitHub', command=self.cmd_bugjar_github)
        self.menu_help.add_command(label='Open BeeWare project page', command=self.cmd_beeware_page)

        # last step - configure the menubar
        self.root['menu'] = self.menubar

    def _setup_button_toolbar(self):
        '''
        The button toolbar runs as a horizontal area at the top of the GUI.
        It is a persistent GUI component
        '''

        # Main toolbar
        self.toolbar = Frame(self.root)
        self.toolbar.grid(column=0, row=0, sticky=(W, E))

        # Buttons on the toolbar
        self.run_button = Button(self.toolbar, text='Run', command=self.cmd_run)
        self.run_button.grid(column=0, row=0)

        self.step_button = Button(self.toolbar, text='Step', command=self.cmd_step)
        self.step_button.grid(column=1, row=0)

        self.next_button = Button(self.toolbar, text='Next', command=self.cmd_next)
        self.next_button.grid(column=2, row=0)

        self.return_button = Button(self.toolbar, text='Return', command=self.cmd_return)
        self.return_button.grid(column=3, row=0)

        self.toolbar.columnconfigure(0, weight=0)
        self.toolbar.rowconfigure(0, weight=0)

    def _setup_main_content(self):
        '''
        Sets up the main content area. It is a persistent GUI component
        '''

        # Main content area
        self.content = PanedWindow(self.root, orient=HORIZONTAL)
        self.content.grid(column=0, row=1, sticky=(N, S, E, W))

        # Create subregions of the content
        self._setup_file_lists()
        self._setup_code_area()
        self._setup_inspector()

        # Set up weights for the left frame's content
        self.content.columnconfigure(0, weight=1)
        self.content.rowconfigure(0, weight=1)

        self.content.pane(0, weight=1)
        self.content.pane(1, weight=2)
        self.content.pane(2, weight=1)

    def _setup_file_lists(self):

        self.file_notebook = Notebook(self.content, padding=(0, 5, 0, 5))
        self.content.add(self.file_notebook)

        self._setup_stack_frame_list()
        self._setup_breakpoint_list()

    def _setup_stack_frame_list(self):
        self.stack_frame = Frame(self.content)
        self.stack_frame.grid(column=0, row=0, sticky=(N, S, E, W))
        self.file_notebook.add(self.stack_frame, text='Stack')

        self.stack = StackView(self.stack_frame, normalizer=self.filename_normalizer)
        self.stack.grid(column=0, row=0, sticky=(N, S, E, W))

        # # The tree's vertical scrollbar
        self.stack_scrollbar = Scrollbar(self.stack_frame, orient=VERTICAL)
        self.stack_scrollbar.grid(column=1, row=0, sticky=(N, S))

        # # Tie the scrollbar to the text views, and the text views
        # # to each other.
        self.stack.config(yscrollcommand=self.stack_scrollbar.set)
        self.stack_scrollbar.config(command=self.stack.yview)

        # Setup weights for the "stack" tree
        self.stack_frame.columnconfigure(0, weight=1)
        self.stack_frame.columnconfigure(1, weight=0)
        self.stack_frame.rowconfigure(0, weight=1)

        # Handlers for GUI events
        self.stack.bind('<<TreeviewSelect>>', self.on_stack_frame_selected)

    def _setup_breakpoint_list(self):
        self.breakpoints_frame = Frame(self.content)
        self.breakpoints_frame.grid(column=0, row=0, sticky=(N, S, E, W))
        self.file_notebook.add(self.breakpoints_frame, text='Breakpoints')

        self.breakpoints = BreakpointView(self.breakpoints_frame, normalizer=self.filename_normalizer)
        self.breakpoints.grid(column=0, row=0, sticky=(N, S, E, W))

        # The tree's vertical scrollbar
        self.breakpoints_scrollbar = Scrollbar(self.breakpoints_frame, orient=VERTICAL)
        self.breakpoints_scrollbar.grid(column=1, row=0, sticky=(N, S))

        # Tie the scrollbar to the text views, and the text views
        # to each other.
        self.breakpoints.config(yscrollcommand=self.breakpoints_scrollbar.set)
        self.breakpoints_scrollbar.config(command=self.breakpoints.yview)

        # Setup weights for the "breakpoint list" tree
        self.breakpoints_frame.columnconfigure(0, weight=1)
        self.breakpoints_frame.columnconfigure(1, weight=0)
        self.breakpoints_frame.rowconfigure(0, weight=1)

        # Handlers for GUI events
        self.breakpoints.tag_bind('breakpoint', '<Double-Button-1>', self.on_breakpoint_double_clicked)
        self.breakpoints.tag_bind('breakpoint', '<<TreeviewSelect>>', self.on_breakpoint_selected)
        self.breakpoints.tag_bind('file', '<<TreeviewSelect>>', self.on_breakpoint_file_selected)

    def _setup_code_area(self):
        self.code_frame = Frame(self.content)
        self.code_frame.grid(column=1, row=0, sticky=(N, S, E, W))

        # Label for current file
        self.current_file = StringVar()
        self.current_file_label = Label(self.code_frame, textvariable=self.current_file)
        self.current_file_label.grid(column=0, row=0, sticky=(W, E))

        # Code display area
        self.code = DebuggerCode(self.code_frame, debugger=self.debugger)
        self.code.grid(column=0, row=1, sticky=(N, S, E, W))

        # Set up weights for the code frame's content
        self.code_frame.columnconfigure(0, weight=1)
        self.code_frame.rowconfigure(0, weight=0)
        self.code_frame.rowconfigure(1, weight=1)

        self.content.add(self.code_frame)

    def _setup_inspector(self):
        self.inspector_frame = Frame(self.content)
        self.inspector_frame.grid(column=2, row=0, sticky=(N, S, E, W))

        self.inspector = InspectorView(self.inspector_frame)
        self.inspector.grid(column=0, row=0, sticky=(N, S, E, W))

        # The tree's vertical scrollbar
        self.inspector_scrollbar = Scrollbar(self.inspector_frame, orient=VERTICAL)
        self.inspector_scrollbar.grid(column=1, row=0, sticky=(N, S))

        # Tie the scrollbar to the text views, and the text views
        # to each other.
        self.inspector.config(yscrollcommand=self.inspector_scrollbar.set)
        self.inspector_scrollbar.config(command=self.inspector.yview)

        # Setup weights for the "breakpoint list" tree
        self.inspector_frame.columnconfigure(0, weight=1)
        self.inspector_frame.columnconfigure(1, weight=0)
        self.inspector_frame.rowconfigure(0, weight=1)

        self.content.add(self.inspector_frame)

    def _setup_status_bar(self):
        # Status bar
        self.statusbar = Frame(self.root)
        self.statusbar.grid(column=0, row=2, sticky=(W, E))

        # Current status
        self.run_status = StringVar()
        self.run_status_label = Label(self.statusbar, textvariable=self.run_status)
        self.run_status_label.grid(column=0, row=0, sticky=(W, E))
        self.run_status.set('Not running')

        # Main window resize handle
        self.grip = Sizegrip(self.statusbar)
        self.grip.grid(column=1, row=0, sticky=(S, E))

        # Set up weights for status bar frame
        self.statusbar.columnconfigure(0, weight=1)
        self.statusbar.columnconfigure(1, weight=0)
        self.statusbar.rowconfigure(0, weight=0)

    ######################################################
    # Utility methods for controlling content
    ######################################################

    def show_file(self, filename, line=None, breakpoints=None):
        """Show the content of the nominated file.

        If specified, line is the current line number to highlight. If the
        line isn't currently visible, the window will be scrolled until it is.

        breakpoints is a list of line numbers that have current breakpoints.

        If refresh is true, the file will be reloaded and redrawn.
        """
        # Set the filename label for the current file
        self.current_file.set(self.filename_normalizer(filename))

        # Update the code view; this means changing the displayed file
        # if necessary, and updating the current line.
        if filename != self.code.filename:
            self.code.filename = filename
            for bp in self.debugger.breakpoints(filename).values():
                if bp.enabled:
                    self.code.enable_breakpoint(bp.line)
                else:
                    self.code.disable_breakpoint(bp.line)

        self.code.line = line

    ######################################################
    # TK Main loop
    ######################################################

    def mainloop(self):
        self.root.mainloop()

    ######################################################
    # TK Command handlers
    ######################################################

    def cmd_quit(self):
        "Quit the debugger"
        self.debugger.stop()
        self.root.quit()

    def cmd_run(self, event=None):
        "Run until the next breakpoint, or end of execution"
        self.debugger.do_run()

    def cmd_step(self, event=None):
        "Step into the next line of code"
        self.debugger.do_step()

    def cmd_next(self, event=None):
        "Run the next line of code in the current frame"
        self.debugger.do_next()

    def cmd_return(self, event=None):
        "Return to the previous frame"
        self.debugger.do_return()

    def cmd_open_file(self, event=None):
        "Open a file in the breakpoint pane"
        filename = tkFileDialog.askopenfilename(initialdir=os.path.abspath(os.getcwd()))

        if filename:
            # Convert to canonical form
            filename = os.path.abspath(filename)
            filename = os.path.normcase(filename)

            # Show the file contents
            self.code.filename = filename

            # Ensure the file appears on the breakpoint list
            self.breakpoints.insert_filename(filename)

            # Show the breakpoint panel
            self.file_notebook.select(self.breakpoints_frame)

            # ... select the new filename
            self.breakpoints.selection_set(filename)

            # .. and clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    def cmd_bugjar_page(self):
        "Show the Bugjar project page"
        webbrowser.open_new('http://pybee.org/bugjar')

    def cmd_bugjar_github(self):
        "Show the Bugjar GitHub repo"
        webbrowser.open_new('http://github.com/pybee/bugjar')

    def cmd_bugjar_docs(self):
        "Show the Bugjar documentation"
        # If this is a formal release, show the docs for that
        # version. otherwise, just show the head docs.
        if len(NUM_VERSION) == 3:
            webbrowser.open_new('http://bugjar.readthedocs.org/en/v%s/' % VERSION)
        else:
            webbrowser.open_new('http://bugjar.readthedocs.org/')

    def cmd_beeware_page(self):
        "Show the BeeWare project page"
        webbrowser.open_new('http://pybee.org/')

    ######################################################
    # Handlers for GUI actions
    ######################################################

    def on_stack_frame_selected(self, event):
        "When a stack frame is selected, highlight the file and line"
        if event.widget.selection():
            _, index = event.widget.selection()[0].split(':')
            line, frame = self.debugger.stack[int(index)]

            # Display the file in the code view
            self.show_file(filename=frame['filename'], line=line)

            # Display the contents of the selected frame in the inspector
            self.inspector.show_frame(frame)

            # Clear any currently selected item on the breakpoint tree
            self.breakpoints.selection_remove(self.breakpoints.selection())

    def on_breakpoint_selected(self, event):
        "When a breakpoint on the tree has been selected, show the breakpoint"
        if event.widget.selection():
            parts = event.widget.focus().split(':')
            bp = self.debugger.breakpoint((parts[0], int(parts[1])))
            self.show_file(filename=bp.filename, line=bp.line)

            # Clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    def on_breakpoint_file_selected(self, event):
        "When a file is selected on the breakpoint tree, show the file"
        if event.widget.selection():
            filename = event.widget.focus()
            self.show_file(filename=filename)

            # Clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    def on_breakpoint_double_clicked(self, event):
        "When a breakpoint on the tree is double clicked, toggle it's status"
        if event.widget.selection():
            parts = event.widget.focus().split(':')
            bp = self.debugger.breakpoint((parts[0], int(parts[1])))
            if bp.enabled:
                self.debugger.disable_breakpoint(bp)
            else:
                self.debugger.enable_breakpoint(bp)

            # Clear any currently selected item on the stack tree
            self.stack.selection_remove(self.stack.selection())

    ######################################################
    # Handlers for debugger responses
    ######################################################

    def on_stack(self, stack):
        "A report of a new stack"
        # Make sure the stack frame list is displayed
        self.file_notebook.select(self.stack_frame)

        # Update the stack list
        self.stack.update_stack(stack)

        if len(stack) > 0:
            # Update the display of the current file
            line = stack[-1][0]
            filename = stack[-1][1]['filename']
            self.show_file(filename=filename, line=line)

            # Select the current stack frame in the frame list
            self.stack.selection_set('frame:%s' % (len(stack) - 1))
        else:
            # No current frame (probably end of execution),
            # so clear the current line marker
            self.code.line = None

    def on_line(self, filename, line):
        "A single line of code has been executed"
        self.run_status.set('Line (%s:%s)' % (filename, line))

    def on_call(self, args):
        "A callable has been invoked"
        self.run_status.set('Call: %s' % args)

    def on_return(self, retval):
        "A callable has returned"
        self.run_status.set('Return: %s' % retval)

    def on_exception(self, name, value):
        "An exception has been raised"
        self.run_status.set('Exception: %s - %s' % (name, value))
        tkMessageBox.showwarning(message='%s: %s' % (name, value))

    def on_postmortem(self):
        "An exception has been raised"
        self.run_status.set('Post mortem mode')
        tkMessageBox.showerror(message='Entering post mortem mode. Step/Next will restart')

    def on_restart(self):
        "The code has finished running, and will start again"
        self.run_status.set('Not running')
        tkMessageBox.showinfo(message='Program has finished, and will restart.')

    def on_info(self, message):
        "The debugger needs to inform the user of something"
        tkMessageBox.showinfo(message=message)

    def on_warning(self, message):
        "The debugger needs to warn the user of something"
        tkMessageBox.showwarning(message=message)

    def on_error(self, message):
        "The debugger needs to report an error"
        tkMessageBox.showerror(message=message)

    def on_breakpoint_enable(self, bp):
        "A breakpoint has been enabled in the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.enable_breakpoint(bp.line, temporary=bp.temporary)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)

    def on_breakpoint_disable(self, bp):
        "A breakpoint has been disabled in the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.disable_breakpoint(bp.line)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)

    def on_breakpoint_ignore(self, bp, count):
        "A breakpoint has been ignored by the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.ignore_breakpoint(bp.line)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)

    def on_breakpoint_clear(self, bp):
        "A breakpoint has been cleared in the debugger"
        # If the breakpoint is in the currently displayed file, updated
        # the display of the breakpoint.
        if bp.filename == self.code.filename:
            self.code.clear_breakpoint(bp.line)

        # ... then update the display of the breakpoint on the tree
        self.breakpoints.update_breakpoint(bp)
예제 #50
0
class GUI:

    ## GUI variables
    titleText = 'PyCX Simulator'  # window title
    timeInterval = 0              # refresh time in milliseconds
    running = False
    modelFigure = None
    stepSize = 1
    currentStep = 0
    def __init__(self,title='PyCX Simulator',interval=0,stepSize=1,parameterSetters=[]):
        self.titleText = title
        self.timeInterval = interval
        self.stepSize = stepSize
        self.parameterSetters = parameterSetters
        self.varEntries = {}
        self.statusStr = ""
               
        self.initGUI()
    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr) 
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW',self.quitGUI)
        self.rootWindow.geometry('550x400')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)
        
        self.notebook = Notebook(self.rootWindow)      
        self.notebook.grid(row=0,column=0,padx=2,pady=2,sticky='nswe')
        

        self.frameRun = Frame()
        self.frameSettings = Frame()
        self.frameParameters = Frame()
        self.frameInformation = Frame()          
        
        self.notebook.add(self.frameRun,text="Run")
        self.notebook.add(self.frameSettings,text="Settings")
        self.notebook.add(self.frameParameters,text="Parameters")
        self.notebook.add(self.frameInformation,text="Info")
     
        self.notebook.pack(expand=YES, fill=BOTH, padx=5, pady=5 ,side=TOP)
        self.status = Label(self.rootWindow, width=40,height=3, relief=SUNKEN, bd=1,textvariable=self.statusText)
        self.status.grid(row=1,column=0,padx=2,pady=2,sticky='nswe')
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)



        
        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameRun,width=30,height=2,textvariable=self.runPauseString,command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)



        self.showHelp(self.buttonRun,"Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameRun,width=30,height=2,text='Step Once',command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep,"Steps the simulation only once")
        self.buttonReset = Button(self.frameRun,width=30,height=2,text='Reset',command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5) 
        self.showHelp(self.buttonReset,"Resets the simulation")
 
   
        
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step size ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can,from_=1, to=50, resolution=1,command=self.changeStepSize,orient=HORIZONTAL, width=25,length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(self.stepScale,"Skips model redraw during every [n] simulation steps\nResults in a faster model run.")
        self.stepScale.pack(side='left')    
        can.pack(side='top')
    
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step visualization delay in ms ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepDelay = Scale(can,from_=0, to=max(2000,self.timeInterval), resolution=10,command=self.changeStepDelay,orient=HORIZONTAL, width=25,length=150)
        self.stepDelay.set(self.timeInterval)
        self.showHelp(self.stepDelay,"The visualization of each step is delays by the given number of milliseconds.")
        self.stepDelay.pack(side='left')    
        can.pack(side='top')
        scrollInfo = Scrollbar(self.frameInformation)
        self.textInformation = Text(self.frameInformation, width=45,height=13,bg='lightgray',wrap=WORD,font=("Courier",10))
        scrollInfo.pack(side=RIGHT, fill=Y)
        self.textInformation.pack(side=LEFT,fill=BOTH,expand=YES)
        scrollInfo.config(command=self.textInformation.yview)
        self.textInformation.config(yscrollcommand=scrollInfo.set)
        for variableSetter in self.parameterSetters:
            can = Canvas(self.frameParameters)
            lab = Label(can, width=25,height=1,text=variableSetter.__name__+" ",anchor=W,takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            ent.insert(0, str(variableSetter()))
            if variableSetter.__doc__ != None and len(variableSetter.__doc__) > 0:
                self.showHelp(ent,variableSetter.__doc__.strip())
            ent.pack(side='left')            
            can.pack(side='top')
            self.varEntries[variableSetter]=ent
        if len(self.parameterSetters) > 0:
            self.buttonSaveParameters = Button(self.frameParameters,width=50,height=1,command=self.saveParametersCmd,text="Save parameters to the running model",state=DISABLED)
            self.showHelp(self.buttonSaveParameters,"Saves the parameter values.\nNot all values may take effect on a running model\nA model reset might be required.")
            self.buttonSaveParameters.pack(side='top',padx=5,pady=5)
            self.buttonSaveParametersAndReset = Button(self.frameParameters,width=50,height=1,command=self.saveParametersAndResetCmd,text="Save parameters to the model and reset the model")
            self.showHelp(self.buttonSaveParametersAndReset,"Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top',padx=5,pady=5)
        
    
    def setStatusStr(self,newStatus):
        self.statusStr = newStatus
        self.statusText.set(self.statusStr)  
    #model control functions
    def changeStepSize(self,val):        
        self.stepSize = int(val)
    def changeStepDelay(self,val):        
        self.timeInterval= int(val)    
    def saveParametersCmd(self):
        for variableSetter in self.parameterSetters:
            variableSetter(float(self.varEntries[variableSetter].get()))
        self.setStatusStr("New parameter values have been set")
    def saveParametersAndResetCmd(self):
        self.saveParametersCmd()
        self.resetModel()

    def runEvent(self):
        self.running = not self.running
        if self.running:
            self.rootWindow.after(self.timeInterval,self.stepModel)
            self.runPauseString.set("Pause")
            self.buttonStep.configure(state=DISABLED)
            self.buttonReset.configure(state=DISABLED)
            if len(self.parameterSetters) > 0:
                self.buttonSaveParameters.configure(state=NORMAL)
                self.buttonSaveParametersAndReset.configure(state=DISABLED)     
        else:
            self.runPauseString.set("Continue Run")
            self.buttonStep.configure(state=NORMAL)
            self.buttonReset.configure(state=NORMAL)
            if len(self.parameterSetters) > 0:
                self.buttonSaveParameters.configure(state=NORMAL)
                self.buttonSaveParametersAndReset.configure(state=NORMAL)

    def stepModel(self):
        if self.running:
            self.modelStepFunc()
            self.currentStep += 1
            self.setStatusStr("Step "+str(self.currentStep))
            self.status.configure(foreground='black')
            if (self.currentStep) % self.stepSize == 0:
                self.drawModel()
            self.rootWindow.after(int(self.timeInterval*1.0/self.stepSize),self.stepModel)

    def stepOnce(self):
        self.running = False
        self.runPauseString.set("Continue Run")
        self.modelStepFunc()
        self.currentStep += 1
        self.setStatusStr("Step "+str(self.currentStep))
        self.drawModel()
        if len(self.parameterSetters) > 0:
            self.buttonSaveParameters.configure(state=NORMAL)

    def resetModel(self):
        self.running = False        
        self.runPauseString.set("Run")
        self.modelInitFunc()
        self.currentStep = 0;
        self.setStatusStr("Model has been reset")
        self.drawModel()

    def drawModel(self):
        
        if self.modelFigure == None or self.modelFigure.canvas.manager.window == None:
            self.modelFigure = PL.figure()
            PL.ion()
        self.modelDrawFunc()
        self.modelFigure.canvas.manager.window.update()

    def start(self,func=[]):
        if len(func)==3:
            self.modelInitFunc = func[0]
            self.modelDrawFunc = func[1]
            self.modelStepFunc = func[2]            
            if (self.modelStepFunc.__doc__ != None and len(self.modelStepFunc.__doc__)>0):
                self.showHelp(self.buttonStep,self.modelStepFunc.__doc__.strip())                
            if (self.modelInitFunc.__doc__ != None and len(self.modelInitFunc.__doc__)>0):
                self.textInformation.config(state=NORMAL)
                self.textInformation.delete(1.0, END)
                self.textInformation.insert(END, self.modelInitFunc.__doc__.strip())
                self.textInformation.config(state=DISABLED)
                
            self.modelInitFunc()
            self.drawModel()     
        self.rootWindow.mainloop()

    def quitGUI(self):
        PL.close('all')
        self.rootWindow.quit()
        self.rootWindow.destroy()
    
    
    
    def showHelp(self, widget,text):
        def setText(self):
            self.statusText.set(text)
            self.status.configure(foreground='blue')
            
        def showHelpLeave(self):
            self.statusText.set(self.statusStr)
            self.status.configure(foreground='black')
        widget.bind("<Enter>", lambda e : setText(self))
        widget.bind("<Leave>", lambda e : showHelpLeave(self))
예제 #51
0
    def __init__(self, master):

        self.fname = ""
        #global variables
        self.t1 = StringVar()
        self.t2 = StringVar()
        self.t3 = StringVar()
        self.t4 = StringVar()
        self.t5 = StringVar()
        self.t6 = StringVar()
        self.t7 = StringVar()
        self.t8 = StringVar()
        self.t9 = StringVar()
        self.t10 = StringVar()

        self.var1 = StringVar()
        self.var2 = StringVar()
        self.var3 = StringVar()
        self.var4 = StringVar()
        self.var5 = StringVar()
        self.var6 = StringVar()
        self.var7 = StringVar()
        self.var8 = StringVar()
        self.var9 = StringVar()
        self.var10 = StringVar()
        #end

        mymaster = Frame(master, name='mymaster')  # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window
        #master.minsize(width=900, height=900)
        #master.maxsize(width=650, height=500)
        #end

        #title of window
        master.title("Airdrop-ng")
        #end

        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont = tkFont.Font(family="Helvetica",
                                      size=15,
                                      underline=True)
        self.myfontnew = tkFont.Font(family="Helvetica",
                                     size=11,
                                     underline=True)
        #end

        nb = Notebook(mymaster, name='nb')  # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3)  # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb, name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Filter-1")  # add tab to Notebook
        self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")

        # repeat for each tab

        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")

        #End

        #frame content 7
        Label(self.frame_content7,
              text='Airdrop-ng',
              font=self.headerfont,
              bg="white",
              padx=10,
              pady=10).grid(row=0, column=0)
        btndetect = Button(self.frame_content7,
                           text='Detect',
                           command=self.canvas_detect,
                           height=2,
                           width=15,
                           font=self.customFont).grid(row=1,
                                                      column=0,
                                                      padx=5,
                                                      pady=5)

        btndbrowse = Button(self.frame_content7,
                            text='Attach File',
                            command=self.browse_file,
                            height=2,
                            width=15,
                            font=self.customFont).grid(row=3,
                                                       column=0,
                                                       padx=5,
                                                       pady=5)
        self.lilnew1 = Listbox(self.frame_content7,
                               bg="black",
                               fg="white",
                               font=self.myfont,
                               selectmode=SINGLE,
                               width=30,
                               height=15)
        self.lilnew1.grid(row=1, column=1, rowspan=3)
        #End

        Label(self.frame_content,
              text='Airdrop-ng',
              font=self.headerfont,
              bg="white",
              padx=10,
              pady=10).grid(row=0, column=0)
        Label(self.frame_content,
              text='Options :',
              font=self.myfontnew,
              bg="white").grid(row=1, column=1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5,
              text='Edit Command From Here',
              font=self.myfontnew,
              bg="white",
              justify=LEFT).grid(row=0, column=0)
        TextCommandBox = Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output = Text(self.frame_content5,
                           bg="black",
                           fg="white",
                           font=self.myfont,
                           height=20,
                           width=42)
        self.output.grid(row=0, column=1, padx=50, pady=5, rowspan=3)
        btnsubmit = Button(self.frame_content5,
                           width=15,
                           height=2,
                           text="Get Result",
                           command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear = Button(self.frame_content5,
                          width=15,
                          height=2,
                          text="Clear Output",
                          command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "-i", \
                 onvalue = "-i", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var1)
        self.C1.grid(row=2, column=0, padx=5, pady=5)
        self.t1 = Text(self.frame_content, height=1, width=20)
        self.t1.grid(row=2, column=1, padx=5, pady=5)
        l1 = Label(self.frame_content,
                   text=': Wireless card in monitor mode to inject from',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=2, column=2, padx=5, pady=5)

        self.C2 = Checkbutton(self.frame_content, text = "-t", \
                 onvalue = "-t", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var2)
        self.C2.grid(row=3, column=0, padx=5, pady=5)
        self.t2 = Text(self.frame_content, height=1, width=20)
        self.t2.grid(row=3, column=1, padx=5, pady=5)
        l2 = Label(self.frame_content,
                   text=': Airodump txt file in CSV format NOT the pcap',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=3, column=2, padx=5, pady=5)

        self.C3 = Checkbutton(self.frame_content, text = "-p", \
                 onvalue = "-p", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row=4, column=0, padx=5, pady=5)
        self.t3 = Text(self.frame_content, height=1, width=20)
        self.t3.grid(row=4, column=1, padx=5, pady=5)
        l3 = Label(self.frame_content,
                   text=': Disable the use of Psyco JIT',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=4, column=2, padx=5, pady=5)

        self.C4 = Checkbutton(self.frame_content, text = "-r", \
                 onvalue = "-r", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row=5, column=0, padx=5, pady=5)
        self.t4 = Text(self.frame_content, height=1, width=20)
        self.t4.grid(row=5, column=1, padx=5, pady=5)
        l4 = Label(self.frame_content,
                   text=': Rule File for matched deauths)',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=5, column=2, padx=5, pady=5)

        self.C5 = Checkbutton(self.frame_content, text = "-u", \
                 onvalue = "-u", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var5)
        self.C5.grid(row=6, column=0, padx=5, pady=5)
        self.t5 = Text(self.frame_content, height=1, width=20)
        self.t5.grid(row=6, column=1, padx=5, pady=5)
        l5 = Label(self.frame_content,
                   text=': Updates OUI list.',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=6, column=2, padx=5, pady=5)

        self.C6 = Checkbutton(self.frame_content, text = "-d", \
                 onvalue = "-d", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var6)
        self.C6.grid(row=8, column=0, padx=5, pady=5)
        self.t6 = Text(self.frame_content, height=1, width=20)
        self.t6.grid(row=8, column=1, padx=5, pady=5)
        l6 = Label(self.frame_content,
                   text=': Injection driver. Default is mac80211.',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=8, column=2, padx=5, pady=5)

        self.C7 = Checkbutton(self.frame_content, text = "-s", \
                 onvalue = "-s", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var7)
        self.C7.grid(row=9, column=0, padx=5, pady=5)
        self.t7 = Text(self.frame_content, height=1, width=20)
        self.t7.grid(row=9, column=1, padx=5, pady=5)
        l7 = Label(self.frame_content,
                   text=': Time to sleep between sending each packet',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=9, column=2, padx=5, pady=5)

        self.C8 = Checkbutton(self.frame_content, text = "-b", \
                onvalue = "-b", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var8)
        self.C8.grid(row=10, column=0, padx=5, pady=5)
        self.t8 = Text(self.frame_content, height=1, width=20)
        self.t8.grid(row=10, column=1, padx=5, pady=5)
        l8 = Label(self.frame_content,
                   text=': Turn on Rule Debugging',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=10, column=2, padx=5, pady=5)

        self.C9 = Checkbutton(self.frame_content, text = "-l", \
                onvalue = "-l", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var9)
        self.C9.grid(row=11, column=0, padx=5, pady=5)
        self.t9 = Text(self.frame_content, height=1, width=20)
        self.t9.grid(row=11, column=1, padx=5, pady=5)
        l9 = Label(self.frame_content,
                   text=': Enable Logging to a file',
                   font=self.myfont,
                   bg="white",
                   justify=LEFT).grid(row=11, column=2, padx=5, pady=5)

        self.C10 = Checkbutton(self.frame_content, text = "-n", \
                onvalue = "-n", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var10)
        self.C10.grid(row=12, column=0, padx=5, pady=5)
        self.t10 = Text(self.frame_content, height=1, width=20)
        self.t10.grid(row=12, column=1, padx=5, pady=5)
        l10 = Label(self.frame_content,
                    text=': Time to sleep between loops',
                    font=self.myfont,
                    bg="white",
                    justify=LEFT).grid(row=12, column=2, padx=5, pady=5)
예제 #52
0
    def __init__(self, master):
        Frame.__init__(self, master)
        self.FileObjects = []
        self.FileObjectNames = []
        self.intSettings = {'Group': IntVar(value=1),
                            'DataObject': IntVar(value=1),
                            'FieldVariables': IntVar(value=1)}

        self.FieldVariables = OrderedDict()

        self.notebook = Notebook(self)
        self.tab1 = Frame(self.notebook)
        self.tab2 = Frame(self.notebook)
        self.notebook.add(self.tab1, text="Data Interaction")
        self.notebook.add(self.tab2, text="Mach-1 Image Grid")
        self.notebook.grid(row=0, column=0, sticky=NW)

        #####  BEGIN TAB 1 #####
        self.frameDataFiles = Frame(self.tab1)
        self.frameDataFiles.grid(row=0, column=0, sticky=N+W+E)
        self.buttonLoadFile = Button(self.frameDataFiles, text="Load Data File",
                                     command=self.loadFile)
        self.buttonLoadFile.grid(row=0, column=0, padx=1, pady=1,
                                 sticky=N+W+E)
        self.buttonRemoveFile = Button(self.frameDataFiles, text="Remove Selected File",
                                       command=self.removeDataObject)
        self.buttonRemoveFile.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)
        self.frameDataObjects = LabelFrame(self.tab1, text="Data Files")
        self.frameDataObjects.grid(row=0, column=1, padx=1, pady=1, sticky=N+W+E)

        self.frameGroups = LabelFrame(self.tab1, text="Group Selection")
        self.frameGroups.grid(row=1, column=0, padx=1, pady=1,
                              sticky=N+W+E )
        Label(self.frameGroups, text="").grid(row=0, column=0, sticky=N+W+E)
        self.frameChannels = LabelFrame(self.tab1, text="Channel Selection")
        self.frameChannels.grid(row=1, column=1, padx=1, pady=1,
                                sticky=N+W+E)
        Label(self.frameChannels, text="").grid(row=0, column=0, sticky=N+W+E)

        self.frameTab1BottomLeft = Frame(self.tab1)
        self.frameTab1BottomLeft.grid(row=2, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonSaveFile = Button(self.frameTab1BottomLeft, text="Save Selected to Pickle",
                                     command=self.saveFile)
        self.buttonSaveFile.grid(row=0, column=0, padx=1, pady=1,
                                 sticky=N+W+E)

        self.buttonSaveCSV = Button(self.frameTab1BottomLeft, text="Save Selected to CSV",
                                    command=self.saveCSV)
        self.buttonSaveCSV.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)

        self.buttonGetThickness = Button(self.frameTab1BottomLeft, text="Get Mach-1 Thicknesses",
                                         command=self.findThicknesses)
        self.buttonGetThickness.grid(row=2, column=0, padx=1, pady=1, sticky=N+W+E)

        self.buttonPlot = Button(self.frameTab1BottomLeft, text="Plot Selected Channels",
                                 command=self.plotChannels)
        self.buttonPlot.grid(row=3, column=0, padx=1, pady=1,
                             sticky=N+W+E)

        self.frameTab1BottomRight = Frame(self.tab1)
        self.frameTab1BottomRight.grid(row=2, column=1, padx=1, pady=1, sticky=N+W+E)
        self.buttonMovingAvg = Button(self.frameTab1BottomRight, text="Apply Moving Average",
                                      command=self.applyMovingAvg)
        self.buttonMovingAvg.grid(row=0, column=0, padx=1, pady=1, columnspan=2,
                                  sticky=N+W+E)
        self.windowSize = IntVar(value=10)
        Label(self.frameTab1BottomRight, text="Window Size").grid(row=1, column=0, padx=1, pady=1,
                                                                  sticky=N+W)
        Entry(self.frameTab1BottomRight, textvariable=self.windowSize, width=4).grid(row=1, column=1, padx=1,
                                                                                     pady=1, sticky=N+W)
        #####  END TAB 1 #####

        ##### BEGIN TAB 2 #####
        self.frameImageButtons = Frame(self.tab2)
        self.frameImageButtons.grid(row=0, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonLoadImage = Button(self.frameImageButtons, text="Load Image",
                                      command=self.loadImage)
        self.buttonLoadImage.grid(row=0, column=0, padx=1, pady=1, sticky=N+W+E)

        self.buttonLoadMapFile = Button(self.frameImageButtons, text="Load Mach-1 Site Locations",
                                        command=self.loadMachMap)

        self.buttonLoadMapFile.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonDefineMask = Button(self.frameImageButtons, text="Define Mask",
                                       command=self.cropImage)
        self.buttonDefineMask.grid(row=2, column=0, padx=1, pady=1, sticky=N+W+E)
        self.buttonClearMask = Button(self.frameImageButtons, text="Clear Mask",
                                      command=self.clearMask)
        self.buttonClearMask.grid(row=3, column=0, padx=1, pady=1, sticky=N+W+E)

        self.frameFieldVariables = LabelFrame(self.tab2, text="Field Variables")
        self.frameFieldVariables.grid(row=1, column=0, padx=1, pady=1, sticky=N+W+E)

        ##### END TAB 2 #####
        self.grid()
예제 #53
0
def report_cash(master, from_date=None, to_date=None, reason=None):
    """Создает и выводи на экран окно с отчетом по блокноту расходов"""


    def press(index):
        """функция, срабатывающая при нажатии кнопок переключения
        между видами сортировок. Переключает вкладки в блокноте"""

        window_names = tabs.tabs()
        tabs.select(window_names[index])


    def make_query_cash(from_date=None, to_date=None, reason=None):
        """Возвращает кортеж запросов для последующего использования при
        составлении отчета по расходам"""

        select = queries.report_cash_query()

        if reason:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.reason == reason:
                        new_select.append(element)
                select[q] = new_select

        if from_date and to_date:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if (element.date_time >= from_date) and \
                       (element.date_time <= to_date + timedelta(days=1)):
                        new_select.append(element)
                select[q] = new_select

        elif from_date:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.date_time >= from_date:
                        new_select.append(element)
                select[q] = new_select

        elif to_date:
            for q in range(len(select)):
                new_select = []
                for element in select[q]:
                    if element.date_time <= to_date + timedelta(days=1):
                        new_select.append(element)
                select[q] = new_select

        return select


    def show(frame, iterator):
        """Выводит на экран выборку, заданную в iterator"""

        scrollbar = Scrollbar(frame)
        tree = Treeview(frame, selectmode='none', padding=3,
                                    style='Custom.Treeview', height=REPORT_HEIGHT,
                                    yscrollcommand=scrollbar.set)
        tree.pack(side=LEFT, fill=BOTH, expand=YES)
        scrollbar.config(command=tree.yview)
        scrollbar.pack(side=LEFT, fill=Y)

        tree.tag_configure('1', font=('Verdana', FONT_SIZE_REPORT))
        tree.tag_configure('2', font=('Verdana', FONT_SIZE_REPORT),
                                                           background='#f5f5ff')

        Style().configure('Custom.Treeview', rowheight=FONT_SIZE_REPORT*2)

        columns = ['#' + str(x + 1) for x in range(5)]
        tree.configure(columns=columns)

        for q in range(len(header)):
            tree.heading('#%d' % (q + 1), text=header[q], anchor='w')
            tree.column('#%d' % (q + 1), width=REPORT_SCALE * col_width[q + 1],
                                                                     anchor='w')
        tree.heading('#0', text='', anchor='w')
        tree.column('#0', width=0, anchor='w', minwidth=0)

        flag = True
        for item in iterator:
            col = []
            col.append(add_s(item.reason.text))
            col.append(add_s(item.summ))
            col.append(add_s(item.comment))
            col.append(add_s(item.date_time.strftime('%d.%m.%Y')))
            col.append(add_s(item.date_time.time())[:8])

            flag = not flag
            if flag:
                tree.insert('', 'end', text='', values=col, tag='2')
            else:
                tree.insert('', 'end', text='', values=col, tag='1')

    # --------------------------------------------#

    tl = Toplevel(master)
    tl.title(u'Отчет по расходам')

    bottom = Frame(tl, relief=SUNKEN)
    bottom.pack(side=BOTTOM, fill=X)

    showArea = []
    tabs = Notebook(tl, style='Hidden.TNotebook')
    for q in range (2):
        frame = Frame(tabs,  height=REPORT_HEIGHT)
        tabs.add(frame, text='')
        showArea.append(frame)
    tabs.pack(side=TOP, fill=BOTH, expand=YES)
    Style().layout('Hidden.TNotebook.Tab', '')

    header = (u'Причина', u'Сумма', u'Комментарий', u'Дата', u'Время')

    col_width = (0, 30, 10, 50, 16, 16)

    query = make_query_cash(from_date, to_date, reason)
    for q in range(len(query)):
        summ = show(showArea[q], query[q])


    Button(bottom, text=u'Сортировка\nпо причине', command=lambda: press(0)
                             ).pack(side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Сортировка\nпо времени', command=lambda:press(1)
                             ).pack(side=LEFT, padx=REPORT_PAD, pady=REPORT_PAD)

    Button(bottom, text=u'Экспорт в\nMS Excel').pack(
                                   side=RIGHT, padx=REPORT_PAD, pady=REPORT_PAD)

    tl.focus_set()
예제 #54
0
    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr) 
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW',self.quitGUI)
        self.rootWindow.geometry('550x400')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)
        
        self.notebook = Notebook(self.rootWindow)      
        self.notebook.grid(row=0,column=0,padx=2,pady=2,sticky='nswe')
        

        self.frameRun = Frame()
        self.frameSettings = Frame()
        self.frameParameters = Frame()
        self.frameInformation = Frame()          
        
        self.notebook.add(self.frameRun,text="Run")
        self.notebook.add(self.frameSettings,text="Settings")
        self.notebook.add(self.frameParameters,text="Parameters")
        self.notebook.add(self.frameInformation,text="Info")
     
        self.notebook.pack(expand=YES, fill=BOTH, padx=5, pady=5 ,side=TOP)
        self.status = Label(self.rootWindow, width=40,height=3, relief=SUNKEN, bd=1,textvariable=self.statusText)
        self.status.grid(row=1,column=0,padx=2,pady=2,sticky='nswe')
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)



        
        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameRun,width=30,height=2,textvariable=self.runPauseString,command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)



        self.showHelp(self.buttonRun,"Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameRun,width=30,height=2,text='Step Once',command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep,"Steps the simulation only once")
        self.buttonReset = Button(self.frameRun,width=30,height=2,text='Reset',command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5) 
        self.showHelp(self.buttonReset,"Resets the simulation")
 
   
        
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step size ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can,from_=1, to=50, resolution=1,command=self.changeStepSize,orient=HORIZONTAL, width=25,length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(self.stepScale,"Skips model redraw during every [n] simulation steps\nResults in a faster model run.")
        self.stepScale.pack(side='left')    
        can.pack(side='top')
    
        can = Canvas(self.frameSettings)
        lab = Label(can, width=25,height=1,text="Step visualization delay in ms ", justify=LEFT, anchor=W,takefocus=0)
        lab.pack(side='left')
        self.stepDelay = Scale(can,from_=0, to=max(2000,self.timeInterval), resolution=10,command=self.changeStepDelay,orient=HORIZONTAL, width=25,length=150)
        self.stepDelay.set(self.timeInterval)
        self.showHelp(self.stepDelay,"The visualization of each step is delays by the given number of milliseconds.")
        self.stepDelay.pack(side='left')    
        can.pack(side='top')
        scrollInfo = Scrollbar(self.frameInformation)
        self.textInformation = Text(self.frameInformation, width=45,height=13,bg='lightgray',wrap=WORD,font=("Courier",10))
        scrollInfo.pack(side=RIGHT, fill=Y)
        self.textInformation.pack(side=LEFT,fill=BOTH,expand=YES)
        scrollInfo.config(command=self.textInformation.yview)
        self.textInformation.config(yscrollcommand=scrollInfo.set)
        for variableSetter in self.parameterSetters:
            can = Canvas(self.frameParameters)
            lab = Label(can, width=25,height=1,text=variableSetter.__name__+" ",anchor=W,takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            ent.insert(0, str(variableSetter()))
            if variableSetter.__doc__ != None and len(variableSetter.__doc__) > 0:
                self.showHelp(ent,variableSetter.__doc__.strip())
            ent.pack(side='left')            
            can.pack(side='top')
            self.varEntries[variableSetter]=ent
        if len(self.parameterSetters) > 0:
            self.buttonSaveParameters = Button(self.frameParameters,width=50,height=1,command=self.saveParametersCmd,text="Save parameters to the running model",state=DISABLED)
            self.showHelp(self.buttonSaveParameters,"Saves the parameter values.\nNot all values may take effect on a running model\nA model reset might be required.")
            self.buttonSaveParameters.pack(side='top',padx=5,pady=5)
            self.buttonSaveParametersAndReset = Button(self.frameParameters,width=50,height=1,command=self.saveParametersAndResetCmd,text="Save parameters to the model and reset the model")
            self.showHelp(self.buttonSaveParametersAndReset,"Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top',padx=5,pady=5)
예제 #55
0
파일: sell.py 프로젝트: sychov/conditer
    def show_sell_bills(master):
        """Заполняет верхний фрейм продаж блокнотом со счетами и
        сответствующими элементами управления."""

        sellTopFrame = Frame(master, relief=GROOVE)
        sellTopFrame.pack(side=TOP, fill=X, padx=10, pady=5)

        #------------------------------------------------------------
        def b_add():
            """Срабатывает при нажатии кнопки "Добавить счет", добавляет таб в
            блокноте со счетами"""

            bill = Bill(note)
            bills.append(bill)
            tab = bill.frame
            note.add(tab, text = show_sell_bills.entry.get())
            button_del_bill.configure(state=NORMAL)

        button_add_bill = Button(sellTopFrame,text=u'Добавить\nсчет',
                        style='Little.TButton', command=b_add)
        button_add_bill.pack(side=LEFT, padx=10, pady=10, fill=X)

        #------------------------------------------------------------
        """Хоть и без отдельной функции, но комментарий расширенный стоит дать.
        Это окошко ввода названия для создаваемого счета"""

        show_sell_bills.entry = StringVar()
        show_sell_bills.entry.set(u'Стол ')
        entry = Entry(sellTopFrame, textvariable=show_sell_bills.entry,
                        font=('verdana', FONT_SIZE))
        entry.pack(side=LEFT, padx=10, pady=10)

        #------------------------------------------------------------
        def b_left():
            """Срабатывает при нажатии кнопки "влево", сдвигается влево на
            один таб в блокноте со счетами"""

            w_name = note.select()
            window_names = note.tabs()
            if window_names:
                index = window_names.index(w_name) - 1
                note.select(window_names[index])

        button_left = Button(sellTopFrame, image=data.IMG_INTERFACE[3],
                                command=b_left)
        button_left.pack(side=LEFT, padx=5, pady=5)

        #------------------------------------------------------------
        def b_right():
            """Срабатывает при нажатии кнопки "вправо", сдвигается вправо на
            один таб в блокноте со счетами"""

            w_name = note.select()
            window_names = note.tabs()
            if window_names:
                index = window_names.index(w_name) + 1
                if index == len(window_names):
                    index = 0
                note.select(window_names[index])

        button_right = Button(sellTopFrame, image=data.IMG_INTERFACE[4],
                                command=b_right)
        button_right.pack(side=LEFT, padx=5, pady=5)

        #------------------------------------------------------------
        def b_del():
            """Срабатывает при нажатии кнопки "удалить счет", удаляет таб в
            блокноте со счетами"""

            w_name = note.select()
            window_names = note.tabs()
            if not window_names:
                button_del_bill.configure(state=DISABLED)
            else:
                index = window_names.index(w_name)
                if not bills[index].bill:
                    note.forget(note.select())
                    del(bills[index])
                    if not note.tabs():
                        button_del_bill.configure(state=DISABLED)
                else:
                    if tkMessageBox.askokcancel('Внимание!',
                                   'Вы уверены, что хотите удалить этот счет?'):
                        note.forget(note.select())
                        del(bills[index])
                        if not note.tabs():
                            button_del_bill.configure(state=DISABLED)

        button_del_bill = Button(sellTopFrame,text=u'Удалить\nсчет',
                        style='Little.TButton', command=b_del)
        button_del_bill.pack(side=LEFT, padx=10, pady=10, fill=X)


        #----- ОСТАВШИЕСЯ ЭЛЕМЕНТЫ - БЛОКНОТ, СЧЕТЧИК ПРОДАЖ, КАЛЬКУЛЯТОР ------

        label = Label(sellTopFrame, text='', bg='white',
                                            font=('Lucida Console', FONT_SIZE))
        label.pack(side=RIGHT, padx=10, pady=5)

        def label_renew():
            """Обновляет счетчик продаж в верхнем правом углу экрана"""
            sold = '%6.2f' % round(queries.sell_in_day(),2) + ' грн.'
            label.configure(text='СЕГОДНЯ ПРОДАНО\n на ' + sold)

        label_renew()
        show_sell_bills.label_renew = label_renew

        #-----------
        button_calc = Button(sellTopFrame, image=data.IMG_INTERFACE[8],
                        command=calculator_press)
        button_calc.pack(side=RIGHT, padx=5, pady=5)

        button_paid = Button(sellTopFrame, image=data.IMG_INTERFACE[10], width=8,
                                     compound=LEFT, text=u'Блокнот\nрасходов',
                                     command=lambda: calc_pad(data))
        button_paid.pack(side=RIGHT, padx=5, pady=5)

        #-----------
        note = Notebook(master, style='Custom.TNotebook')
        bills = []
        note.pack(side=TOP, padx=BILL_PAD_X, pady=BILL_PAD_Y)

        #----------- Один пустой столик ставим по умолчанию ----------
        bill = Bill(note)
        bills.append(bill)
        tab = bill.frame
        note.add(tab, text = u' Стол 1 ')
        #-------------------------------------------------------------

        #--------Автоподъем высоты ------------
        sellTopFrame.update()
        y1 = sellTopFrame.winfo_height()
        y2 = note.winfo_height()
        master.configure(height = y1 + y2 + 40)
        master.pack_propagate(False)
        #---------------------------------------

        calculator_press.window_calc = False

        return bills, note
예제 #56
0
 def notebook(self):
     tabFrame = Notebook(self.root)
예제 #57
0
class wm_seg:
    """
    Simple GUI application
    If the application inside a container, automatic updates are removed.

    The application uses two frames (tabs):
    - training
    - testing
    """
    def __init__(self, master, container):

        self.master = master
        master.title("nicMSlesions")

        # running on a container
        self.container = container

        # gui attributes
        self.path = os.getcwd()
        self.default_config = None
        self.user_config = None
        self.current_folder = os.getcwd()
        self.list_train_pretrained_nets = []
        self.list_test_nets = []
        self.version = __version__
        if self.container is False:
            # version_number
            self.commit_version = subprocess.check_output(
                ['git', 'rev-parse', 'HEAD'])

        # queue and thread parameters. All processes are embedded
        # inside threads to avoid freezing the application
        self.train_task = None
        self.test_task = None
        self.test_queue = Queue.Queue()
        self.train_queue = Queue.Queue()

        # --------------------------------------------------
        # parameters. Mostly from the config/*.cfg files
        # --------------------------------------------------

        # data parameters
        self.param_training_folder = StringVar()
        self.param_test_folder = StringVar()
        self.param_FLAIR_tag = StringVar()
        self.param_T1_tag = StringVar()
        self.param_MOD3_tag = StringVar()
        self.param_MOD4_tag = StringVar()
        self.param_mask_tag = StringVar()
        self.param_model_tag = StringVar()
        self.param_register_modalities = BooleanVar()
        self.param_skull_stripping = BooleanVar()
        self.param_denoise = BooleanVar()
        self.param_denoise_iter = IntVar()
        self.param_save_tmp = BooleanVar()
        self.param_debug = BooleanVar()

        # train parameters
        self.param_net_folder = os.path.join(self.current_folder, 'nets')
        self.param_use_pretrained_model = BooleanVar()
        self.param_pretrained_model = StringVar()
        self.param_inference_model = StringVar()
        self.param_num_layers = IntVar()
        self.param_net_name = StringVar()
        self.param_net_name.set('None')
        self.param_balanced_dataset = StringVar()
        self.param_fract_negatives = DoubleVar()

        # model parameters
        self.param_pretrained = None
        self.param_min_th = DoubleVar()
        self.param_patch_size = IntVar()
        self.param_weight_paths = StringVar()
        self.param_load_weights = BooleanVar()
        self.param_train_split = DoubleVar()
        self.param_max_epochs = IntVar()
        self.param_patience = IntVar()
        self.param_batch_size = IntVar()
        self.param_net_verbose = IntVar()
        self.param_t_bin = DoubleVar()
        self.param_l_min = IntVar()
        self.param_min_error = DoubleVar()
        self.param_mode = BooleanVar()
        self.param_gpu_number = IntVar()

        # load the default configuration from the conf file
        self.load_default_configuration()

        # self frame (tabbed notebook)
        self.note = Notebook(self.master)
        self.note.pack()

        os.system('cls' if platform.system() == 'Windows' else 'clear')
        print "##################################################"
        print "# ------------                                   #"
        print "# nicMSlesions                                   #"
        print "# ------------                                   #"
        print "# MS WM lesion segmentation                      #"
        print "#                                                #"
        print "# -------------------------------                #"
        print "# (c) Sergi Valverde 2018                        #"
        print "# Neuroimage Computing Group                     #"
        print "# -------------------------------                #"
        print "##################################################\n"
        print "Please select options for training or inference in the menu..."

        # --------------------------------------------------
        # training tab
        # --------------------------------------------------
        self.train_frame = Frame()
        self.note.add(self.train_frame, text="Training")
        self.test_frame = Frame()
        self.note.add(self.test_frame, text="Inference")

        # label frames
        cl_s = 5
        self.tr_frame = LabelFrame(self.train_frame, text="Training images:")
        self.tr_frame.grid(row=0,
                           columnspan=cl_s,
                           sticky='WE',
                           padx=5,
                           pady=5,
                           ipadx=5,
                           ipady=5)
        self.model_frame = LabelFrame(self.train_frame, text="CNN model:")
        self.model_frame.grid(row=5,
                              columnspan=cl_s,
                              sticky='WE',
                              padx=5,
                              pady=5,
                              ipadx=5,
                              ipady=5)

        # training options
        self.inFolderLbl = Label(self.tr_frame, text="Training folder:")
        self.inFolderLbl.grid(row=0, column=0, sticky='E', padx=5, pady=2)
        self.inFolderTxt = Entry(self.tr_frame)
        self.inFolderTxt.grid(row=0,
                              column=1,
                              columnspan=5,
                              sticky="W",
                              pady=3)
        self.inFileBtn = Button(self.tr_frame,
                                text="Browse ...",
                                command=self.load_training_path)
        self.inFileBtn.grid(row=0,
                            column=5,
                            columnspan=1,
                            sticky='W',
                            padx=5,
                            pady=1)

        self.optionsBtn = Button(self.tr_frame,
                                 text="Other options",
                                 command=self.parameter_window)
        self.optionsBtn.grid(row=0,
                             column=10,
                             columnspan=1,
                             sticky="W",
                             padx=(100, 1),
                             pady=1)

        # setting input modalities: FLAIR + T1 are mandatory
        # Mod 3 / 4 are optional
        self.flairTagLbl = Label(self.tr_frame, text="FLAIR tag:")
        self.flairTagLbl.grid(row=1, column=0, sticky='E', padx=5, pady=2)
        self.flairTxt = Entry(self.tr_frame, textvariable=self.param_FLAIR_tag)
        self.flairTxt.grid(row=1, column=1, columnspan=1, sticky="W", pady=1)

        self.t1TagLbl = Label(self.tr_frame, text="T1 tag:")
        self.t1TagLbl.grid(row=2, column=0, sticky='E', padx=5, pady=2)
        self.t1Txt = Entry(self.tr_frame, textvariable=self.param_T1_tag)
        self.t1Txt.grid(row=2, column=1, columnspan=1, sticky="W", pady=1)

        self.mod3TagLbl = Label(self.tr_frame, text="mod 3 tag:")
        self.mod3TagLbl.grid(row=3, column=0, sticky='E', padx=5, pady=2)
        self.mod3Txt = Entry(self.tr_frame, textvariable=self.param_MOD3_tag)
        self.mod3Txt.grid(row=3, column=1, columnspan=1, sticky="W", pady=1)

        self.mod4TagLbl = Label(self.tr_frame, text="mod 4 tag:")
        self.mod4TagLbl.grid(row=4, column=0, sticky='E', padx=5, pady=2)
        self.mod4Txt = Entry(self.tr_frame, textvariable=self.param_MOD4_tag)
        self.mod4Txt.grid(row=4, column=1, columnspan=1, sticky="W", pady=1)

        self.maskTagLbl = Label(self.tr_frame, text="MASK tag:")
        self.maskTagLbl.grid(row=5, column=0, sticky='E', padx=5, pady=2)
        self.maskTxt = Entry(self.tr_frame, textvariable=self.param_mask_tag)
        self.maskTxt.grid(row=5, column=1, columnspan=1, sticky="W", pady=1)

        # model options
        self.modelTagLbl = Label(self.model_frame, text="Model name:")
        self.modelTagLbl.grid(row=6, column=0, sticky='E', padx=5, pady=2)
        self.modelTxt = Entry(self.model_frame,
                              textvariable=self.param_net_name)
        self.modelTxt.grid(row=6, column=1, columnspan=1, sticky="W", pady=1)

        self.checkPretrain = Checkbutton(self.model_frame,
                                         text="use pretrained",
                                         var=self.param_use_pretrained_model)
        self.checkPretrain.grid(row=6, column=3, padx=5, pady=5)

        self.update_pretrained_nets()

        self.pretrainTxt = OptionMenu(self.model_frame,
                                      self.param_pretrained_model,
                                      *self.list_train_pretrained_nets)
        self.pretrainTxt.grid(row=6, column=5, sticky='E', padx=5, pady=5)

        # START button links
        self.trainingBtn = Button(self.train_frame,
                                  state='disabled',
                                  text="Start training",
                                  command=self.train_net)
        self.trainingBtn.grid(row=7, column=0, sticky='W', padx=1, pady=1)

        # --------------------------------------------------
        # inference tab
        # --------------------------------------------------
        self.tt_frame = LabelFrame(self.test_frame, text="Inference images:")
        self.tt_frame.grid(row=0,
                           columnspan=cl_s,
                           sticky='WE',
                           padx=5,
                           pady=5,
                           ipadx=5,
                           ipady=5)
        self.test_model_frame = LabelFrame(self.test_frame, text="CNN model:")
        self.test_model_frame.grid(row=5,
                                   columnspan=cl_s,
                                   sticky='WE',
                                   padx=5,
                                   pady=5,
                                   ipadx=5,
                                   ipady=5)

        # testing options
        self.test_inFolderLbl = Label(self.tt_frame, text="Testing folder:")
        self.test_inFolderLbl.grid(row=0, column=0, sticky='E', padx=5, pady=2)
        self.test_inFolderTxt = Entry(self.tt_frame)
        self.test_inFolderTxt.grid(row=0,
                                   column=1,
                                   columnspan=5,
                                   sticky="W",
                                   pady=3)
        self.test_inFileBtn = Button(self.tt_frame,
                                     text="Browse ...",
                                     command=self.load_testing_path)
        self.test_inFileBtn.grid(row=0,
                                 column=5,
                                 columnspan=1,
                                 sticky='W',
                                 padx=5,
                                 pady=1)

        self.test_optionsBtn = Button(self.tt_frame,
                                      text="Other options",
                                      command=self.parameter_window)
        self.test_optionsBtn.grid(row=0,
                                  column=10,
                                  columnspan=1,
                                  sticky="W",
                                  padx=(100, 1),
                                  pady=1)

        self.test_flairTagLbl = Label(self.tt_frame, text="FLAIR tag:")
        self.test_flairTagLbl.grid(row=1, column=0, sticky='E', padx=5, pady=2)
        self.test_flairTxt = Entry(self.tt_frame,
                                   textvariable=self.param_FLAIR_tag)
        self.test_flairTxt.grid(row=1,
                                column=1,
                                columnspan=1,
                                sticky="W",
                                pady=1)

        self.test_t1TagLbl = Label(self.tt_frame, text="T1 tag:")
        self.test_t1TagLbl.grid(row=2, column=0, sticky='E', padx=5, pady=2)
        self.test_t1Txt = Entry(self.tt_frame, textvariable=self.param_T1_tag)
        self.test_t1Txt.grid(row=2, column=1, columnspan=1, sticky="W", pady=1)

        self.test_mod3TagLbl = Label(self.tt_frame, text="mod 3 tag:")
        self.test_mod3TagLbl.grid(row=3, column=0, sticky='E', padx=5, pady=2)
        self.test_mod3Txt = Entry(self.tt_frame,
                                  textvariable=self.param_MOD3_tag)
        self.test_mod3Txt.grid(row=3,
                               column=1,
                               columnspan=1,
                               sticky="W",
                               pady=1)

        self.test_mod4TagLbl = Label(self.tt_frame, text="mod 4 tag:")
        self.test_mod4TagLbl.grid(row=4, column=0, sticky='E', padx=5, pady=2)
        self.test_mod4Txt = Entry(self.tt_frame,
                                  textvariable=self.param_MOD4_tag)
        self.test_mod4Txt.grid(row=4,
                               column=1,
                               columnspan=1,
                               sticky="W",
                               pady=1)

        self.test_pretrainTxt = OptionMenu(self.test_model_frame,
                                           self.param_inference_model,
                                           *self.list_test_nets)

        self.param_inference_model.set('None')
        self.test_pretrainTxt.grid(row=5, column=0, sticky='E', padx=5, pady=5)

        # START button links cto docker task
        self.inferenceBtn = Button(self.test_frame,
                                   state='disabled',
                                   text="Start inference",
                                   command=self.infer_segmentation)
        self.inferenceBtn.grid(row=7, column=0, sticky='W', padx=1, pady=1)

        # train / test ABOUT button
        self.train_aboutBtn = Button(self.train_frame,
                                     text="about",
                                     command=self.about_window)
        self.train_aboutBtn.grid(row=7,
                                 column=4,
                                 sticky='E',
                                 padx=(1, 1),
                                 pady=1)

        self.test_aboutBtn = Button(self.test_frame,
                                    text="about",
                                    command=self.about_window)
        self.test_aboutBtn.grid(row=7,
                                column=4,
                                sticky='E',
                                padx=(1, 1),
                                pady=1)

        # Processing state
        self.process_indicator = StringVar()
        self.process_indicator.set(' ')
        self.label_indicator = Label(master,
                                     textvariable=self.process_indicator)
        self.label_indicator.pack(side="left")

        # Closing processing events is implemented via
        # a master protocol
        self.master.protocol("WM_DELETE_WINDOW", self.close_event)

    def parameter_window(self):
        """
        Setting other parameters using an emerging window
        CNN parameters, CUDA device, post-processing....

        """
        t = Toplevel(self.master)
        t.wm_title("Other parameters")

        # data parameters
        t_data = LabelFrame(t, text="data options:")
        t_data.grid(row=0, sticky="WE")
        checkPretrain = Checkbutton(t_data,
                                    text="Register modalities",
                                    var=self.param_register_modalities)
        checkPretrain.grid(row=0, sticky='W')
        checkSkull = Checkbutton(t_data,
                                 text="Skull-strip modalities",
                                 var=self.param_skull_stripping)
        checkSkull.grid(row=1, sticky="W")
        checkDenoise = Checkbutton(t_data,
                                   text="Denoise masks",
                                   var=self.param_denoise)
        checkDenoise.grid(row=2, sticky="W")

        denoise_iter_label = Label(t_data,
                                   text=" Denoise iter:               ")
        denoise_iter_label.grid(row=3, sticky="W")
        denoise_iter_entry = Entry(t_data,
                                   textvariable=self.param_denoise_iter)
        denoise_iter_entry.grid(row=3, column=1, sticky="E")

        check_tmp = Checkbutton(t_data,
                                text="Save tmp files",
                                var=self.param_save_tmp)
        check_tmp.grid(row=4, sticky="W")
        checkdebug = Checkbutton(t_data,
                                 text="Debug mode",
                                 var=self.param_debug)
        checkdebug.grid(row=5, sticky="W")

        # model parameters
        t_model = LabelFrame(t, text="Model:")
        t_model.grid(row=5, sticky="EW")

        maxepochs_label = Label(t_model, text="Max epochs:                  ")
        maxepochs_label.grid(row=6, sticky="W")
        maxepochs_entry = Entry(t_model, textvariable=self.param_max_epochs)
        maxepochs_entry.grid(row=6, column=1, sticky="E")

        trainsplit_label = Label(t_model, text="Validation %:           ")
        trainsplit_label.grid(row=7, sticky="W")
        trainsplit_entry = Entry(t_model, textvariable=self.param_train_split)
        trainsplit_entry.grid(row=7, column=1, sticky="E")

        batchsize_label = Label(t_model, text="Test batch size:")
        batchsize_label.grid(row=8, sticky="W")
        batchsize_entry = Entry(t_model, textvariable=self.param_batch_size)
        batchsize_entry.grid(row=8, column=1, sticky="E")

        mode_label = Label(t_model, text="Verbosity:")
        mode_label.grid(row=9, sticky="W")
        mode_entry = Entry(t_model, textvariable=self.param_net_verbose)
        mode_entry.grid(row=9, column=1, sticky="E")

        #gpu_mode = Checkbutton(t_model,
        #                         text="GPU:",
        #                         var=self.param_mode)
        #gpu_mode.grid(row=10, sticky="W")

        gpu_number = Label(t_model, text="GPU number:")
        gpu_number.grid(row=10, sticky="W")
        gpu_entry = Entry(t_model, textvariable=self.param_gpu_number)
        gpu_entry.grid(row=10, column=1, sticky="W")

        # training parameters
        tr_model = LabelFrame(t, text="Training:")
        tr_model.grid(row=12, sticky="EW")

        balanced_label = Label(tr_model, text="Balanced dataset:    ")
        balanced_label.grid(row=13, sticky="W")
        balanced_entry = Entry(tr_model,
                               textvariable=self.param_balanced_dataset)
        balanced_entry.grid(row=13, column=1, sticky="E")

        fraction_label = Label(tr_model, text="Fraction negative/positives: ")
        fraction_label.grid(row=14, sticky="W")
        fraction_entry = Entry(tr_model,
                               textvariable=self.param_fract_negatives)
        fraction_entry.grid(row=14, column=1, sticky="E")

        # postprocessing parameters
        t_post = LabelFrame(t, text="Post-processing:  ")
        t_post.grid(row=15, sticky="EW")
        t_bin_label = Label(t_post, text="Out probability th:      ")
        t_bin_label.grid(row=16, sticky="W")
        t_bin_entry = Entry(t_post, textvariable=self.param_t_bin)
        t_bin_entry.grid(row=16, column=1, sticky="E")

        l_min_label = Label(t_post, text="Min out region size:         ")
        l_min_label.grid(row=17, sticky="W")
        l_min_entry = Entry(t_post, textvariable=self.param_l_min)
        l_min_entry.grid(row=17, column=1, sticky="E")

        vol_min_label = Label(t_post, text="Min vol error (ml):   ")
        vol_min_label.grid(row=18, sticky="W")
        vol_min_entry = Entry(t_post, textvariable=self.param_min_error)
        vol_min_entry.grid(row=18, column=1, sticky="E")

    def load_default_configuration(self):
        """
        load the default configuration from /config/default.cfg
        This method assign each of the configuration parameters to
        class attributes
        """

        default_config = ConfigParser.SafeConfigParser()
        default_config.read(os.path.join(self.path, 'config', 'default.cfg'))

        # dastaset parameters
        self.param_training_folder.set(
            default_config.get('database', 'train_folder'))
        self.param_test_folder.set(
            default_config.get('database', 'inference_folder'))
        self.param_FLAIR_tag.set(default_config.get('database', 'flair_tags'))
        self.param_T1_tag.set(default_config.get('database', 't1_tags'))
        self.param_MOD3_tag.set(default_config.get('database', 'mod3_tags'))
        self.param_MOD4_tag.set(default_config.get('database', 'mod4_tags'))
        self.param_mask_tag.set(default_config.get('database', 'roi_tags'))
        self.param_register_modalities.set(
            default_config.get('database', 'register_modalities'))
        self.param_denoise.set(default_config.get('database', 'denoise'))
        self.param_denoise_iter.set(
            default_config.getint('database', 'denoise_iter'))
        self.param_skull_stripping.set(
            default_config.get('database', 'skull_stripping'))
        self.param_save_tmp.set(default_config.get('database', 'save_tmp'))
        self.param_debug.set(default_config.get('database', 'debug'))

        # train parameters
        self.param_use_pretrained_model.set(
            default_config.get('train', 'full_train'))
        self.param_pretrained_model.set(
            default_config.get('train', 'pretrained_model'))
        self.param_inference_model.set("      ")
        self.param_balanced_dataset.set(
            default_config.get('train', 'balanced_training'))
        self.param_fract_negatives.set(
            default_config.getfloat('train', 'fraction_negatives'))

        # model parameters
        self.param_net_folder = os.path.join(self.current_folder, 'nets')
        self.param_net_name.set(default_config.get('model', 'name'))
        self.param_train_split.set(
            default_config.getfloat('model', 'train_split'))
        self.param_max_epochs.set(default_config.getint('model', 'max_epochs'))
        self.param_patience.set(default_config.getint('model', 'patience'))
        self.param_batch_size.set(default_config.getint('model', 'batch_size'))
        self.param_net_verbose.set(default_config.get('model', 'net_verbose'))
        self.param_gpu_number.set(default_config.getint('model', 'gpu_number'))
        # self.param_mode.set(default_config.get('model', 'gpu_mode'))

        # post-processing
        self.param_l_min.set(default_config.getint('postprocessing', 'l_min'))
        self.param_t_bin.set(default_config.getfloat('postprocessing',
                                                     't_bin'))
        self.param_min_error.set(
            default_config.getfloat('postprocessing', 'min_error'))

    def write_user_configuration(self):
        """
        write the configuration into config/configuration.cfg
        """
        user_config = ConfigParser.RawConfigParser()

        # dataset parameters
        user_config.add_section('database')
        user_config.set('database', 'train_folder',
                        self.param_training_folder.get())
        user_config.set('database', 'inference_folder',
                        self.param_test_folder.get())
        user_config.set('database', 'flair_tags', self.param_FLAIR_tag.get())
        user_config.set('database', 't1_tags', self.param_T1_tag.get())
        user_config.set('database', 'mod3_tags', self.param_MOD3_tag.get())
        user_config.set('database', 'mod4_tags', self.param_MOD4_tag.get())
        user_config.set('database', 'roi_tags', self.param_mask_tag.get())

        user_config.set('database', 'register_modalities',
                        self.param_register_modalities.get())
        user_config.set('database', 'denoise', self.param_denoise.get())
        user_config.set('database', 'denoise_iter',
                        self.param_denoise_iter.get())
        user_config.set('database', 'skull_stripping',
                        self.param_skull_stripping.get())
        user_config.set('database', 'save_tmp', self.param_save_tmp.get())
        user_config.set('database', 'debug', self.param_debug.get())

        # train parameters
        user_config.add_section('train')
        user_config.set('train', 'full_train',
                        not (self.param_use_pretrained_model.get()))
        user_config.set('train', 'pretrained_model',
                        self.param_pretrained_model.get())
        user_config.set('train', 'balanced_training',
                        self.param_balanced_dataset.get())
        user_config.set('train', 'fraction_negatives',
                        self.param_fract_negatives.get())
        # model parameters
        user_config.add_section('model')
        user_config.set('model', 'name', self.param_net_name.get())
        user_config.set('model', 'pretrained', self.param_pretrained)
        user_config.set('model', 'train_split', self.param_train_split.get())
        user_config.set('model', 'max_epochs', self.param_max_epochs.get())
        user_config.set('model', 'patience', self.param_patience.get())
        user_config.set('model', 'batch_size', self.param_batch_size.get())
        user_config.set('model', 'net_verbose', self.param_net_verbose.get())
        # user_config.set('model', 'gpu_mode', self.param_mode.get())
        user_config.set('model', 'gpu_number', self.param_gpu_number.get())

        # postprocessing parameters
        user_config.add_section('postprocessing')
        user_config.set('postprocessing', 't_bin', self.param_t_bin.get())
        user_config.set('postprocessing', 'l_min', self.param_l_min.get())
        user_config.set('postprocessing', 'min_error',
                        self.param_min_error.get())

        # Writing our configuration file to 'example.cfg'
        with open(os.path.join(self.path, 'config', 'configuration.cfg'),
                  'wb') as configfile:
            user_config.write(configfile)

    def load_training_path(self):
        """
        Select training path from disk and write it.
        If the app is run inside a container,
        link the iniitaldir with /data
        """
        initialdir = '/data' if self.container else os.getcwd()
        fname = askdirectory(initialdir=initialdir)
        if fname:
            try:
                self.param_training_folder.set(fname)
                self.inFolderTxt.delete(0, END)
                self.inFolderTxt.insert(0, self.param_training_folder.get())
                self.trainingBtn['state'] = 'normal'
            except:
                pass

    def load_testing_path(self):
        """
        Selecet the inference path from disk and write it
        If the app is run inside a container,
        link the iniitaldir with /data
        """
        initialdir = '/data' if self.container else os.getcwd()
        fname = askdirectory(initialdir=initialdir)
        if fname:
            try:
                self.param_test_folder.set(fname)
                self.test_inFolderTxt.delete(0, END)
                self.test_inFolderTxt.insert(0, self.param_test_folder.get())
                self.inferenceBtn['state'] = 'normal'
            except:
                pass

    def update_pretrained_nets(self):
        """
        get a list of the  different net configuration present in the system.
        Each model configuration is represented by a folder containing the network
        weights for each of the networks. The baseline net config is always
        included by default

        """
        folders = os.listdir(self.param_net_folder)
        self.list_train_pretrained_nets = folders
        self.list_test_nets = folders

    def write_to_console(self, txt):
        """
        to doc:
        important method
        """
        self.command_out.insert(END, str(txt))

    def write_to_test_console(self, txt):
        """
        to doc:
        important method
        """
        self.test_command_out.insert(END, str(txt))

    def infer_segmentation(self):
        """
        Method implementing the inference process:
        - Check network selection
        - write the configuration to disk
        - Run the process on a new thread
        """

        if self.param_inference_model.get() == 'None':
            print "ERROR: Please, select a network model before starting...\n"
            return
        if self.test_task is None:
            self.inferenceBtn.config(state='disabled')
            self.param_net_name.set(self.param_inference_model.get())
            self.param_use_pretrained_model.set(False)
            self.write_user_configuration()
            print "\n-----------------------"
            print "Running configuration:"
            print "-----------------------"
            print "Inference model:", self.param_model_tag.get()
            print "Inference folder:", self.param_test_folder.get(), "\n"

            print "Method info:"
            print "------------"
            self.test_task = ThreadedTask(self.write_to_test_console,
                                          self.test_queue,
                                          mode='testing')
            self.test_task.start()
            self.master.after(100, self.process_container_queue)

    def train_net(self):
        """
        Method implementing the training process:
        - write the configuration to disk
        - Run the process on a new thread
        """

        if self.param_net_name.get() == 'None':
            print "ERROR: Please, define network name before starting...\n"
            return

        self.trainingBtn['state'] = 'disable'

        if self.train_task is None:
            self.trainingBtn.update()
            self.write_user_configuration()
            print "\n-----------------------"
            print "Running configuration:"
            print "-----------------------"
            print "Train model:", self.param_net_name.get()
            print "Training folder:", self.param_training_folder.get(), "\n"

            print "Method info:"
            print "------------"

            self.train_task = ThreadedTask(self.write_to_console,
                                           self.test_queue,
                                           mode='training')
            self.train_task.start()
            self.master.after(100, self.process_container_queue)

    def check_update(self):
        """
            check update version and propose to download it if differnt
            So far, a rudimentary mode is used to check the last version.
            """

        # I have to discard possible local changes :(
        print "---------------------------------------"
        print "Updating software"
        print "current version:", self.commit_version

        remote_commit = subprocess.check_output(['git', 'stash'])
        remote_commit = subprocess.check_output(['git', 'fetch'])
        remote_commit = subprocess.check_output(
            ['git', 'rev-parse', 'origin/master'])

        if remote_commit != self.commit_version:
            proc = subprocess.check_output(['git', 'pull', 'origin', 'master'])
            self.check_link.config(text="Updated")
            self.commit_version = remote_commit
            print "updated version:", self.commit_version
        else:
            print "This software is already in the latest version"
        print "---------------------------------------"

    def about_window(self):
        """
        Window showing information about the software and
        version number, including auto-update. If the application
        is run from a container, then auto-update is disabled
        """
        def callback(event):
            """
            open webbrowser when clicking links
            """
            webbrowser.open_new(event.widget.cget("text"))

        # main window
        t = Toplevel(self.master, width=500, height=500)
        t.wm_title("About")

        # NIC logo + name
        title = Label(t,
                      text="nicMSlesions v" + self.version + "\n"
                      "Multiple Sclerosis White Matter Lesion Segmentation")
        title.grid(row=2, column=1, padx=20, pady=10)
        img = ImageTk.PhotoImage(Image.open('./logonic.png'))
        imglabel = Label(t, image=img)
        imglabel.image = img
        imglabel.grid(row=1, column=1, padx=10, pady=10)
        group_name = Label(t,
                           text="Copyright Sergi Valverde (2018-) \n " +
                           "NeuroImage Computing Group")
        group_name.grid(row=3, column=1)
        group_link = Label(t,
                           text=r"http://atc.udg.edu/nic",
                           fg="blue",
                           cursor="hand2")
        group_link.grid(row=4, column=1)
        group_link.bind("<Button-1>", callback)

        license_content = "Licensed under the BSD 2-Clause license. \n" + \
                          "A copy of the license is present in the root directory."

        license_label = Label(t, text=license_content)
        license_label.grid(row=5, column=1, padx=20, pady=20)

        # if self.container is False:
        #     # check version and updates
        #     version_number = Label(t, text="commit: " + self.commit_version)
        #     version_number.grid(row=6, column=1, padx=20, pady=(1, 1))
        #
        #     self.check_link = Button(t,
        #                         text="Check for updates",
        #                         command=self.check_update)
        #     self.check_link.grid(row=7, column=1)

    def process_container_queue(self):
        """
        Process the threading queue. When the threaded processes are
        finished, buttons are reset and a message is shown in the app.
        """
        self.process_indicator.set('Running... please wait')
        try:
            msg = self.test_queue.get(0)
            self.process_indicator.set('Done. See log for more details.')
            self.inferenceBtn['state'] = 'normal'
            self.trainingBtn['state'] = 'normal'
        except Queue.Empty:
            self.master.after(100, self.process_container_queue)

    def close_event(self):
        """
        Stop the thread processes using OS related calls.
        """
        if self.train_task is not None:
            self.train_task.stop_process()
        if self.test_task is not None:
            self.test_task.stop_process()
        os.system('cls' if platform.system == "Windows" else 'clear')
        root.destroy()