Esempio n. 1
0
 def show_properties(self):
     """
     This method displays image properties over new window.
     :return: None
     """
     prop_win = tk.Toplevel()
     prop_win.title("iSyntax Properties")
     prop_win_width = self._window.winfo_screenwidth() * Constants.property_win_size_ratio[0]
     prop_win_height = self._window.winfo_screenheight() * Constants.property_win_size_ratio[1]
     prop_win.geometry("{}x{}+200+100".format(str(int(prop_win_width)),
                                              str(int(prop_win_height))))
     prop_canvas = tk.Canvas(prop_win)
     scroll_y = tk.Scrollbar(prop_win, orient='vertical', command=prop_canvas.yview)
     scroll_x = tk.Scrollbar(prop_win, orient='horizontal', command=prop_canvas.xview)
     frame = tk.Frame(prop_canvas)
     row = 0
     for prop in Constants.property_list:
         # Dynamically create Label Widgets for each property
         # Structure them in a grid
         tk.Label(frame, text=prop[0], foreground='black',
                  font="Calibri 12").grid(sticky="w", row=row)
         tk.Label(frame, text=":", font="Calibri 14").grid(sticky="w", row=row, column=1)
         tk.Label(frame, text=str(prop[1]), foreground='blue',
                  font="Calibri 14").grid(sticky="w", row=row, column=2)
         row += 1
     prop_canvas.create_window(0, 0, anchor='nw', window=frame)
     prop_canvas.update_idletasks()
     scroll_y.pack(fill='y', side='right')
     scroll_x.pack(fill='x', side='bottom')
     prop_canvas.configure(scrollregion=prop_canvas.bbox('all'), yscrollcommand=scroll_y.set,
                           xscrollcommand=scroll_x.set)
     prop_canvas.pack(fill='both', expand=True, side='left')
Esempio n. 2
0
def create_widgets():
    global list_box, canvas

    list_box = tkinter.Listbox(root, exportselection=False)
    list_box.grid(row=0, column=0, rowspan=2, sticky=tkinter.NS)

    list_box.bind('<<ListboxSelect>>', show_cardset)

    scroll_bar = tkinter.Scrollbar(root)
    scroll_bar.grid(row=0, column=1, rowspan=2, sticky=tkinter.NS)
    list_box.config(yscrollcommand=scroll_bar.set)
    scroll_bar.config(command=list_box.yview)

    # create Canvas
    canvas = tkinter.Canvas(root, width=600, height=600, bg='#5eab6b')
    canvas.grid(row=0, column=2, sticky=tkinter.NSEW)
    canvas.bind('<4>', lambda e: canvas.yview_scroll(-5, 'unit'))
    canvas.bind('<5>', lambda e: canvas.yview_scroll(5, 'unit'))
    canvas.bind_all("<MouseWheel>", on_mousewheel)

    scroll_bar = tkinter.Scrollbar(root)
    scroll_bar.grid(row=0, column=3, sticky=tkinter.NS)
    canvas.config(yscrollcommand=scroll_bar.set)
    scroll_bar.config(command=canvas.yview)

    scroll_bar = tkinter.Scrollbar(root, orient=tkinter.HORIZONTAL)
    scroll_bar.grid(row=1, column=2, sticky=tkinter.EW)
    canvas.config(xscrollcommand=scroll_bar.set)
    scroll_bar.config(command=canvas.xview)

    # create buttons
    b_frame = tkinter.Frame(root)
    b_frame.grid(row=3, column=0, columnspan=4, sticky=tkinter.EW)

    button = tkinter.Button(b_frame, text='Quit',
                            command=root.destroy, width=8)
    button.pack(side=tkinter.RIGHT)

    button = tkinter.Button(b_frame, text='Info', command=show_info, width=8)
    button.pack(side=tkinter.RIGHT)

    button = tkinter.Button(b_frame, text='Config',
                            command=show_config, width=8)
    button.pack(side=tkinter.RIGHT)

    button = tkinter.Button(b_frame, text='Select Directory',
                            command=select_dir, width=14)
    button.place(x=200, y=0)

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

    root.title('Show Cardsets')
    root.wm_geometry("%dx%d+%d+%d" % (800, 600, 40, 40))
    return root
Esempio n. 3
0
    def __init__(self, parent, **kwargs):
        tk.Frame.__init__(self, parent)

        text_ops = funcs.extract_args(kwargs, TEXT_KEYS, TEXT_KEY)
        text = tk.Text(self, **text_ops)

        scrollbar_ops = funcs.extract_args(kwargs, SCROLLBAR_KEYS,
                                           SCROLLBAR_KEY)
        vsb = tk.Scrollbar(self, command=text.yview, **scrollbar_ops)
        text.configure(yscrollcommand=vsb.set)
        vsb.pack(side="right", fill="y")
        text.pack(side="left", fill="both", expand=True)
        text.tag_configure('br', lmargin2=80, tabs=35)

        # expose some text methods as methods on this object
        self.insert = text.insert
        self.delete = text.delete
        self.get = text.get
        self.index = text.index
        self.search = text.search
        self.see = text.see
        # self.state = lambda: change_state(self.text)
        self.enable = lambda: funcs.set_state_normal(text)
        self.disable = lambda: funcs.set_state_disabled(text)
        self.clear = text.delete(1.0, tk.END)
Esempio n. 4
0
 def createHbar(self):
     self.hbar = tkinter.Scrollbar(self.frame, takefocus=0,
                                   orient="horizontal")
     self.canvas["xscrollcommand"] = self._setHbar
     self.hbar["command"] = self.canvas.xview
     self.hbar.grid(row=1, column=0, sticky="we")
     self.hbar.grid_remove()
Esempio n. 5
0
    def __init__(self):
        # ===============GUI items initializarion===============
        self.root = Tk.Tk()
        self.root.wm_title("MathsPhysics")

        self.text_frame = Tk.Frame(master=self.root)
        self.text = Tk.Text(self.text_frame)
        self.text_scrollbar = Tk.Scrollbar(self.text_frame)
        self.text.config(yscrollcommand=self.text_scrollbar.set)
        self.text.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=1)
        self.text_scrollbar.config(command=self.text.yview)
        self.text_scrollbar.pack(side=Tk.RIGHT, fill=Tk.Y)

        self.fig = plt.figure(figsize=(5, 5))  #(dpi=100) # figsize=(5, 4),
        self.canvas = FigureCanvasTkAgg(self.fig,
                                        master=self.root)  # A tk.DrawingArea.
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH,
                                         expand=1)  # canvas.draw()
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.root)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.text_frame.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.menubar = Tk.Menu(self.root)
        self.filemenu = Tk.Menu(self.menubar, tearoff=0)
        self.filemenu.add_command(label="Load input", command=self._load_data)
        self.filemenu.add_command(label="Triangulate",
                                  command=self._triangulate)
        self.filemenu.add_command(label="Compare", command=self._compare)
        self.filemenu.add_command(label="Set conditions",
                                  command=self._ask_conds)
        self.filemenu.add_command(label="Solve",
                                  command=self._solve)  # Do nothing
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Quit", command=self._quit)
        self.menubar.add_cascade(label="Menu", menu=self.filemenu)
        self.root.config(menu=self.menubar)

        # conditions window
        self.cond_window = None
        # ============================================================

        self.delaunay_triangulation = None
        self.entries = None
        self.fem_solver = None
        self.solver = None
        self.solution = None
        self.x_vertices = None
        self.y_vertices = None

        # =============================================================
        self.tester = None
Esempio n. 6
0
    def initLayout(self):
        self.editor = tk.Text(self)
        self.editor.grid(row=0, column=0, sticky="nesw")

        scrollbar = tk.Scrollbar(self, command=self.editor.yview)
        scrollbar.grid(row=0, column=1, sticky="nesw")
        self.editor["yscrollcommand"] = scrollbar.set

        self.actionsWidget = TimActionsWidget(master=self)
        self.actionsWidget.grid(row=1, column=0, sticky="w")

        self.grid_rowconfigure(0, weight=10)
        self.grid_rowconfigure(1, weight=1)
Esempio n. 7
0
    def initLayout(self):
        self.choiceWidget = ParChoiceWidget(master=self)
        self.choiceWidget.grid(row=0, column=0, sticky='nw')

        self.editor = tk.Text(self)
        self.editor.grid(row=1, column=0, sticky='nesw')

        scrollbar = tk.Scrollbar(self, command=self.editor.yview)
        scrollbar.grid(row=1, column=1, sticky='nesw')
        self.editor['yscrollcommand'] = scrollbar.set

        self.actionsWidget = ParActionsWidget(master=self)
        self.actionsWidget.grid(row=2, column=0, sticky='w')

        self.grid_rowconfigure(0, weight=1)
        self.grid_rowconfigure(1, weight=10)
        self.grid_rowconfigure(2, weight=1)
Esempio n. 8
0
    def __init__(self):
        self.root = Tk.Tk()
        self.root.wm_title("MathsPhysics")

        self.text_frame = Tk.Frame(master=self.root)
        self.text = Tk.Text(self.text_frame)
        self.text_scrollbar = Tk.Scrollbar(self.text_frame)
        self.text.config(yscrollcommand=self.text_scrollbar.set)
        self.text.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=1)
        self.text_scrollbar.config(command=self.text.yview)
        self.text_scrollbar.pack(side=Tk.RIGHT, fill=Tk.Y)

        self.fig = plt.figure(figsize=(5, 5))  #(dpi=100) # figsize=(5, 4),
        self.canvas = FigureCanvasTkAgg(self.fig,
                                        master=self.root)  # A tk.DrawingArea.
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH,
                                         expand=1)  # canvas.draw()
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.root)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.text_frame.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.menubar = Tk.Menu(self.root)
        self.filemenu = Tk.Menu(self.menubar, tearoff=0)
        self.filemenu.add_command(label="Load input", command=self.load_data)
        self.filemenu.add_command(label="Triangulate",
                                  command=self.triangulate)
        self.filemenu.add_command(label="Compare", command=self.compare)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Quit", command=self._quit)
        self.menubar.add_cascade(label="Menu", menu=self.filemenu)
        self.root.config(menu=self.menubar)

        self.A = None
        self.B = None
        self.filepath = None
        self.angle = None
        self.area = None
        self.points = None
        self.segments = None
        self.data = None
        self.holes = None
        self.labels = False
        self.number_triangles = False
        self.vertices = None
Esempio n. 9
0
 def history_present(self, history):
     window = tkinter.Toplevel(self.tk)
     listbox = tkinter.Listbox(window)
     listbox.pack(side=tkinter.LEFT, fill=tkinter.BOTH, expand=1)
     scrollbar = tkinter.Scrollbar(window, orient=tkinter.VERTICAL)
     scrollbar.config(command=listbox.yview)
     scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
     listbox.config(yscrollcommand=scrollbar.set)
     # insert data
     items = history.getlist()
     for line in items:
         listbox.insert(tkinter.END, line)
     listbox.bind(
         "<Double-Button-1>", lambda e: self._history_selected(
             window, items, listbox.curselection()))
     listbox.bind(
         "<Return>", lambda e: self._history_selected(
             window, items, listbox.curselection()))
     listbox.focus_set()
Esempio n. 10
0
    def __init__(self, parent, title, usernames=[], **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)
        #
        listbox = tkinter.Listbox(top_frame)
        listbox.pack(side='left', fill='both', expand=True)
        scrollbar = tkinter.Scrollbar(top_frame)
        scrollbar.pack(side='right', fill='y')
        listbox.configure(yscrollcommand=scrollbar.set)
        scrollbar.configure(command=listbox.yview)

        self.username = None
        self.listbox = listbox
        bind(listbox, '<<ListboxSelect>>', self.updateUserName)
        #
        for un in usernames:
            listbox.insert('end', un)
        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
Esempio n. 11
0
    def __init__(self, parent, app=None, home=None):
        self.parent = parent
        self.app = app
        self.home = home
        self.url = None
        self.history = Struct(
            list=[],
            index=0,
        )
        self.visited_urls = []
        # need to keep a reference because of garbage collection
        self.images = {}
        self.defcursor = parent["cursor"]
        # self.defcursor = 'xterm'
        self.handcursor = "hand2"

        # create buttons
        button_width = 8
        self.homeButton = tkinter.Button(parent, text=_("Index"),
                                         width=button_width,
                                         command=self.goHome)
        self.homeButton.grid(row=0, column=0, sticky='w')
        self.backButton = tkinter.Button(parent, text=_("Back"),
                                         width=button_width,
                                         command=self.goBack)
        self.backButton.grid(row=0, column=1, sticky='w')
        self.forwardButton = tkinter.Button(parent, text=_("Forward"),
                                            width=button_width,
                                            command=self.goForward)
        self.forwardButton.grid(row=0, column=2, sticky='w')
        self.closeButton = tkinter.Button(parent, text=_("Close"),
                                          width=button_width,
                                          command=self.destroy)
        self.closeButton.grid(row=0, column=3, sticky='e')

        # create text widget
        text_frame = tkinter.Frame(parent)
        text_frame.grid(row=1, column=0, columnspan=4, sticky='nsew')
        text_frame.grid_propagate(False)
        vbar = tkinter.Scrollbar(text_frame)
        vbar.pack(side='right', fill='y')
        self.text = tkinter.Text(text_frame,
                                 fg='black', bg='white',
                                 bd=1, relief='sunken',
                                 cursor=self.defcursor,
                                 wrap='word', padx=10)
        self.text.pack(side='left', fill='both', expand=True)
        self.text["yscrollcommand"] = vbar.set
        vbar["command"] = self.text.yview

        # statusbar
        self.statusbar = HtmlStatusbar(parent, row=2, column=0, columnspan=4)

        parent.columnconfigure(2, weight=1)
        parent.rowconfigure(1, weight=1)

        # load images
        for name, fn in self.symbols_fn.items():
            self.symbols_img[name] = self.getImage(fn)

        self.initBindings()
    def __init__(self, parent, title, init_font, **kw):
        # print init_font
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        self.font_family = 'Helvetica'
        self.font_size = 12
        self.font_weight = 'normal'
        self.font_slant = 'roman'

        if init_font is not None:
            assert 2 <= len(init_font) <= 4
            assert isinstance(init_font[1], int)
            self.font_family, self.font_size = init_font[:2]
            if len(init_font) > 2:
                if init_font[2] in ['bold', 'normal']:
                    self.font_weight = init_font[2]
                elif init_font[2] in ['italic', 'roman']:
                    self.font_slant = init_font[2]
                else:
                    raise ValueError('invalid font style: ' + init_font[2])
                if len(init_font) > 3:
                    if init_font[3] in ['bold', 'normal']:
                        self.font_weight = init_font[3]
                    elif init_font[2] in ['italic', 'roman']:
                        self.font_slant = init_font[3]
                    else:
                        raise ValueError('invalid font style: ' + init_font[3])

        # self.family_var = tkinter.StringVar()
        self.weight_var = tkinter.BooleanVar()
        self.slant_var = tkinter.BooleanVar()
        self.size_var = tkinter.IntVar()

        frame = tkinter.Frame(top_frame)
        frame.pack(expand=True, fill='both', padx=5, pady=10)
        frame.columnconfigure(0, weight=1)
        # frame.rowconfigure(1, weight=1)
        self.entry = tkinter.Entry(frame, bg='white')
        self.entry.grid(row=0, column=0, columnspan=2, sticky='news')
        self.entry.insert('end', _('abcdefghABCDEFGH'))
        self.list_box = tkinter.Listbox(frame, width=36, exportselection=False)
        sb = tkinter.Scrollbar(frame)
        self.list_box.configure(yscrollcommand=sb.set)
        sb.configure(command=self.list_box.yview)
        self.list_box.grid(row=1, column=0, sticky='news')  # rowspan=4
        sb.grid(row=1, column=1, sticky='ns')
        bind(self.list_box, '<<ListboxSelect>>', self.fontupdate)
        # self.list_box.focus()
        cb1 = tkinter.Checkbutton(frame,
                                  anchor='w',
                                  text=_('Bold'),
                                  command=self.fontupdate,
                                  variable=self.weight_var)
        cb1.grid(row=2, column=0, columnspan=2, sticky='we')
        cb2 = tkinter.Checkbutton(frame,
                                  anchor='w',
                                  text=_('Italic'),
                                  command=self.fontupdate,
                                  variable=self.slant_var)
        cb2.grid(row=3, column=0, columnspan=2, sticky='we')

        sc = tkinter.Scale(
            frame,
            from_=6,
            to=40,
            resolution=1,
            # label='Size',
            orient='horizontal',
            command=self.fontupdate,
            variable=self.size_var)
        sc.grid(row=4, column=0, columnspan=2, sticky='news')
        #
        self.size_var.set(self.font_size)
        self.weight_var.set(self.font_weight == 'bold')
        self.slant_var.set(self.font_slant == 'italic')
        font_families = list(tkinter_font.families())
        font_families.sort()
        selected = -1
        n = 0
        self.list_box.insert('end', *font_families)
        for font in font_families:
            if font.lower() == self.font_family.lower():
                selected = n
                break
            n += 1
        if selected >= 0:
            self.list_box.select_set(selected)
            self.list_box.see(selected)
        #
        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)

        self.font = (self.font_family, self.font_size, self.font_slant,
                     self.font_weight)
 def __init__(self, parent, title, cardset, images, **kw):
     kw = self.initKw(kw)
     MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
     top_frame, bottom_frame = self.createFrames(kw)
     self.createBitmaps(top_frame, kw)
     frame = tkinter.Frame(top_frame)
     frame.pack(fill="both", expand=True, padx=5, pady=10)
     #
     #
     info_frame = tkinter.LabelFrame(frame, text=_('About cardset'))
     info_frame.grid(row=0,
                     column=0,
                     columnspan=2,
                     sticky='ew',
                     padx=0,
                     pady=5,
                     ipadx=5,
                     ipady=5)
     styles = nationalities = year = None
     if cardset.si.styles:
         styles = '\n'.join([CSI.STYLE[i] for i in cardset.si.styles])
     if cardset.si.nationalities:
         nationalities = '\n'.join(
             [CSI.NATIONALITY[i] for i in cardset.si.nationalities])
     if cardset.year:
         year = str(cardset.year)
     row = 0
     for n, t in (
             # ('Version:', str(cardset.version)),
         (_('Type:'), CSI.TYPE[cardset.type]),
         (_('Styles:'), styles),
         (_('Nationality:'), nationalities),
         (_('Year:'), year),
             # (_('Number of cards:'), str(cardset.ncards)),
         (_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
     ):
         if t is not None:
             label = tkinter.Label(info_frame,
                                   text=n,
                                   anchor='w',
                                   justify='left')
             label.grid(row=row, column=0, sticky='nw')
             label = tkinter.Label(info_frame,
                                   text=t,
                                   anchor='w',
                                   justify='left')
             label.grid(row=row, column=1, sticky='nw')
             row += 1
     if images:
         try:
             from random import choice
             im = choice(images)
             f = os.path.join(cardset.dir, cardset.backname)
             self.back_image = loadImage(file=f)
             canvas = tkinter.Canvas(info_frame,
                                     width=2 * im.width() + 30,
                                     height=im.height() + 2)
             canvas.create_image(10, 1, image=im, anchor='nw')
             canvas.create_image(im.width() + 20,
                                 1,
                                 image=self.back_image,
                                 anchor='nw')
             canvas.grid(row=0, column=2, rowspan=row + 1, sticky='ne')
             info_frame.columnconfigure(2, weight=1)
             info_frame.rowconfigure(row, weight=1)
         except Exception:
             pass
     # bg = top_frame["bg"]
     bg = 'white'
     text_w = tkinter.Text(frame,
                           bd=1,
                           relief="sunken",
                           wrap="word",
                           padx=4,
                           width=64,
                           height=16,
                           bg=bg)
     text_w.grid(row=1, column=0, sticky='nsew')
     sb = tkinter.Scrollbar(frame)
     sb.grid(row=1, column=1, sticky='ns')
     text_w.configure(yscrollcommand=sb.set)
     sb.configure(command=text_w.yview)
     frame.columnconfigure(0, weight=1)
     frame.rowconfigure(1, weight=1)
     #
     text = ''
     f = os.path.join(cardset.dir, "COPYRIGHT")
     try:
         text = open(f).read()
     except Exception:
         pass
     if text:
         text_w.config(state="normal")
         text_w.insert("insert", text)
     text_w.config(state="disabled")
     #
     focus = self.createButtons(bottom_frame, kw)
     # focus = text_w
     self.mainloop(focus, kw.timeout)
Esempio n. 14
0
 def createVbar(self):
     self.vbar = tkinter.Scrollbar(self.frame, takefocus=0)
     self.canvas["yscrollcommand"] = self._setVbar
     self.vbar["command"] = self.canvas.yview
     self.vbar.grid(row=0, column=1, sticky="ns")
     self.vbar.grid_remove()
Esempio n. 15
0
    def __init__(self, parent, title, app, manager, key=None, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)
        #
        if key is None:
            key = manager.getSelected()
        self.app = app
        self.manager = manager
        self.key = key
        self.table_color = app.opt.colors['table']
        if self.TreeDataHolder_Class.data is None:
            self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key)
        #
        sw = self.top.winfo_screenwidth()
        sh = self.top.winfo_screenheight()

        h = int(sh * .8)
        w = int(sw * .8)
        w1 = int(min(275, sw / 2.5))
        geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2))
        self.top.wm_minsize(400, 200)

        padx, pady = 4, 4

        paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
        paned_window.pack(expand=True, fill='both', padx=8, pady=8)
        left_frame = ttk.Frame(paned_window)
        right_frame = ttk.Frame(paned_window)
        paned_window.add(left_frame)
        paned_window.add(right_frame)

        notebook = ttk.Notebook(left_frame)
        notebook.pack(expand=True, fill='both')
        tree_frame = ttk.Frame(notebook)
        notebook.add(tree_frame, text=_('Tree View'))
        search_frame = ttk.Frame(notebook)
        notebook.add(search_frame, text=_('Search'))

        font = app.getFont("default")
        padx, pady = 4, 4
        self.tree = self.Tree_Class(self, tree_frame, key=key,
                                    default=kw.default,
                                    font=font, width=w1)
        self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')

        # Search
        searchText = tkinter.StringVar()
        self.list_searchlabel = tkinter.Label(search_frame, text="Search:",
                                              justify='left', anchor='w')
        self.list_searchlabel.pack(side="top", fill='both', ipadx=1)
        self.list_searchtext = tkinter.Entry(search_frame,
                                             textvariable=searchText)
        self.list_searchtext.pack(side="top", fill='both',
                                  padx=padx, pady=pady, ipadx=1)
        searchText.trace('w', self.performSearch)

        self.list_scrollbar = tkinter.Scrollbar(search_frame)
        self.list_scrollbar.pack(side="right", fill='both')

        self.createBitmaps(search_frame, kw)
        self.list = tkinter.Listbox(search_frame, exportselection=False)
        self.list.pack(padx=padx, pady=pady, expand=True, side='left',
                       fill='both', ipadx=1)
        self.updateSearchList("")
        bind(self.list, '<<ListboxSelect>>', self.selectSearchResult)
        bind(self.list, '<FocusOut>',
             lambda e: self.list.selection_clear(0, 'end'))

        self.list.config(yscrollcommand=self.list_scrollbar.set)
        self.list_scrollbar.config(command=self.list.yview)

        self.preview = MfxScrolledCanvas(right_frame, hbar=0, vbar=0)
        self.preview.pack(side="right", fill='both', expand=True,
                          padx=padx, pady=pady)

        self.preview.canvas.preview = 1
        # create a preview of the current state
        self.preview_key = -1
        self.updatePreview(key)
        #
        focus = self.createButtons(bottom_frame, kw)
        focus = self.tree.frame

        self.mainloop(focus, kw.timeout, geometry=geometry)
Esempio n. 16
0
    def __init__(self, dm, master=None, *args, **kwargs):
        tkinter.Frame.__init__(self, master, *args, **kwargs)

        self.dm = dm
        n = dm.n_actuators
        self.dm_pattern = numpy.full((n), 0.5)

        ## We have a lot of Scales so we want a scrollbar.  For this,
        ## create a Canvas and insert the Scales inside.  The Scrollbar is
        ## associated with the canvas and controls the Canvas window.
        ## However, we would be forced to manage the position of the
        ## Scales inside the Canvas so instead we create another Frame to
        ## hold the Scales and place that Frame inside the Canvas.
        ##
        ## This is because in tk, scrollbars are their own widgets that
        ## are associated to other widgets.  They can only be associated
        ## with a small set of Widgets, the ones that support the standard
        ## scrollbar interface, such as Listbox, Text, Canvas, and Entry.
        ## So we can't associated the Scrollbar directly with a Frame.

        self.canvas = tkinter.Canvas(self)
        self.canvas_frame = tkinter.Frame(self.canvas)

        zero_button = tkinter.Button(self.canvas_frame,
                                     text="Set all actuators to 0.5",
                                     command=self.zero)
        zero_button.pack(fill='x')
        self.zero_button = zero_button

        self.sliders = [None] * n
        for i in range(n):
            callback = lambda s, i=i: self.set_actuator(i, float(s))
            slider = tkinter.Scale(self.canvas_frame,
                                   orient='horizontal',
                                   from_=0,
                                   to=1,
                                   resolution=0.01,
                                   label="actuator #%i" % i,
                                   command=callback)
            slider.set(0.5)
            slider.pack(fill='x')
            self.sliders[i] = slider

        self.canvas.pack(side='left', fill='both', expand=True)

        self.scrollbar = tkinter.Scrollbar(self.canvas,
                                           command=self.canvas.yview)
        self.scrollbar.pack(side='right', fill='y')

        self.canvas.configure(yscrollcommand=self.scrollbar.set,
                              scrollregion=self.canvas.bbox('all'))

        self.canvas_window = self.canvas.create_window(
            (0, 0), window=self.canvas_frame, anchor='nw')

        ## Moving scrollbar will trigger configure on canvas_frame.
        ## Resizing DeformableMirror Frame on the Y axis will trigger canvas.
        ## Resizing DeformableMirror Frame on the X axis will trigger both
        ## canvas and canvas_frame.
        self.canvas.bind('<Configure>', self.on_canvas_configure)
        self.canvas_frame.bind('<Configure>', self.on_canvas_frame_configure)
Esempio n. 17
0
    def createWidgets(self):

        self.chatFrame = tk.Frame(self)
        self.chatFrame.grid(row=0,
                            column=0,
                            rowspan=10,
                            sticky=tk.S + tk.N + tk.E + tk.W)
        self.chatBox = tk.Text(self.chatFrame, height=10)
        self.chatBox.grid(row=0, column=0, sticky=tk.S + tk.N + tk.E + tk.W)
        self.chatBox.bind("<Key>", lambda e: "break")
        self.sscr = tk.Scrollbar(self.chatFrame)
        self.sscr.grid(column=1, row=0, sticky=tk.N + tk.S + tk.W + tk.E)
        self.chatBox.config(yscrollcommand=self.sscr.set)
        self.sscr.config(command=self.chatBox.yview)
        self.chatFrame.columnconfigure(0, weight=1)
        self.chatFrame.rowconfigure(0, weight=1)

        self.usersFrame = tk.Frame(self)
        self.usersFrame.grid(column=1,
                             row=0,
                             rowspan=15,
                             padx=5,
                             sticky=tk.N + tk.S + tk.W + tk.E)
        scr = tk.Scrollbar(self.usersFrame)
        scr.grid(column=1, row=1, sticky=tk.N + tk.S + tk.W + tk.E)

        userLabel = tk.Label(self.usersFrame, text='User list:').grid(
            column=0, row=0, sticky=tk.N + tk.S + tk.E + tk.W)
        self.userList = tk.Listbox(self.usersFrame)
        self.userList.insert(0, 'ALL')
        self.userList.activate(0)

        self.userList.grid(column=0, row=1, sticky=tk.N + tk.S + tk.E + tk.W)
        self.userList.config(yscrollcommand=scr.set)
        scr.config(command=self.userList.yview)

        self.usersFrame.columnconfigure(0, weight=1)
        self.usersFrame.rowconfigure(0, weight=1)
        self.usersFrame.rowconfigure(1, weight=15)

        self.messageBox = tk.Text(self, height=3)
        self.messageBox.grid(row=10,
                             column=0,
                             rowspan=5,
                             sticky=tk.S + tk.N + tk.E + tk.W)

        self.sendButton = tk.Button(self, text='Send Message')
        self.sendButton.myName = "Send Button"
        self.sendButton.grid(row=15,
                             column=0,
                             sticky=tk.N + tk.S + tk.E + tk.W)
        self.sendButton.bind("<Button-1>", self.send)
        self.exitButton = tk.Button(self, text='Exit')
        self.exitButton.myName = "Exit Button"
        self.exitButton.grid(row=15,
                             column=1,
                             sticky=tk.N + tk.S + tk.E + tk.W)
        self.exitButton.bind("<Button-1>", self.exit)

        self.master.bind_all("<Return>", self.send)

        for i in range(16):
            self.rowconfigure(i, weight=1)
        self.columnconfigure(0, weight=3)
        self.columnconfigure(1, weight=1)
Esempio n. 18
0
    def __init__(self, parent, title, app, gameid, bookmark=None, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)

        self.createBitmaps(top_frame, kw)
        #
        self.app = app
        self.gameid = gameid
        self.bookmark = bookmark
        self.random = None
        if self.TreeDataHolder_Class.data is None:
            self.TreeDataHolder_Class.data = self.TreeData_Class(app)
        #
        sw = self.top.winfo_screenwidth()
        sh = self.top.winfo_screenheight()

        h = int(sh * .8)
        w = int(sw * .8)
        w1 = int(min(275, sw / 2.5))
        geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2))
        self.top.wm_minsize(400, 200)

        # print sw, w1, w2
        # w2 = max(200, min(w2, 10 + 12 * (app.subsampled_images.CARDW + 10)))
        # print sw, w1, w2
        # padx, pady = kw.padx, kw.pady
        # padx, pady = kw.padx/2, kw.pady/2
        padx, pady = 4, 4
        # PanedWindow
        paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
        paned_window.pack(expand=True, fill='both', padx=8, pady=8)
        left_frame = ttk.Frame(paned_window)
        right_frame = ttk.Frame(paned_window)
        paned_window.add(left_frame)
        paned_window.add(right_frame)

        notebook = ttk.Notebook(left_frame)
        notebook.pack(expand=True, fill='both')
        tree_frame = ttk.Frame(notebook)
        notebook.add(tree_frame, text=_('Tree View'))
        search_frame = ttk.Frame(notebook)
        notebook.add(search_frame, text=_('Search'))

        # Tree
        font = app.getFont("default")
        self.tree = self.Tree_Class(self,
                                    tree_frame,
                                    key=gameid,
                                    default=kw.default,
                                    font=font,
                                    width=w1)
        self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')

        # Search
        searchText = tkinter.StringVar()
        self.list_searchlabel = tkinter.Label(search_frame,
                                              text="Search:",
                                              justify='left',
                                              anchor='w')
        self.list_searchlabel.pack(side="top", fill='both', ipadx=1)
        self.list_searchtext = tkinter.Entry(search_frame,
                                             textvariable=searchText)
        self.list_searchtext.pack(side="top",
                                  fill='both',
                                  padx=padx,
                                  pady=pady,
                                  ipadx=1)
        searchText.trace('w', self.performSearch)

        self.list_scrollbar = tkinter.Scrollbar(search_frame)
        self.list_scrollbar.pack(side="right", fill='both')

        self.createBitmaps(search_frame, kw)
        self.list = tkinter.Listbox(search_frame, exportselection=False)
        self.list.pack(padx=padx,
                       pady=pady,
                       expand=True,
                       side='left',
                       fill='both',
                       ipadx=1)
        self.updateSearchList("")
        bind(self.list, '<<ListboxSelect>>', self.selectSearchResult)
        bind(self.list, '<FocusOut>',
             lambda e: self.list.selection_clear(0, 'end'))

        self.list.config(yscrollcommand=self.list_scrollbar.set)
        self.list_scrollbar.config(command=self.list.yview)

        # LabelFrame
        info_frame = ttk.LabelFrame(right_frame, text=_('About game'))
        info_frame.grid(row=0,
                        column=0,
                        padx=padx,
                        pady=pady,
                        ipadx=4,
                        ipady=4,
                        sticky='nws')
        stats_frame = ttk.LabelFrame(right_frame, text=_('Statistics'))
        stats_frame.grid(row=0,
                         column=1,
                         padx=padx,
                         pady=pady,
                         ipadx=4,
                         ipady=4,
                         sticky='nws')
        # Info
        self.info_labels = {}
        for n, t, f, row in (
            ('name', _('Name:'), info_frame, 0),
            ('altnames', _('Alternate names:'), info_frame, 1),
            ('category', _('Category:'), info_frame, 2),
            ('type', _('Type:'), info_frame, 3),
            ('skill_level', _('Skill level:'), info_frame, 4),
            ('decks', _('Decks:'), info_frame, 5),
            ('redeals', _('Redeals:'), info_frame, 6),
                #
            ('played', _('Played:'), stats_frame, 0),
            ('won', _('Won:'), stats_frame, 1),
            ('lost', _('Lost:'), stats_frame, 2),
            ('time', _('Playing time:'), stats_frame, 3),
            ('moves', _('Moves:'), stats_frame, 4),
            ('percent', _('% won:'), stats_frame, 5),
        ):
            title_label = ttk.Label(f, text=t, justify='left', anchor='w')
            title_label.grid(row=row, column=0, sticky='nw', padx=4)
            text_label = ttk.Label(f, justify='left', anchor='w')
            text_label.grid(row=row, column=1, sticky='nw', padx=4)
            self.info_labels[n] = (title_label, text_label)
        # info_frame.columnconfigure(1, weight=1)
        info_frame.rowconfigure(6, weight=1)
        stats_frame.rowconfigure(6, weight=1)
        # Canvas
        self.preview = MfxScrolledCanvas(right_frame)
        self.preview.setTile(app, app.tabletile_index, force=True)
        self.preview.grid(row=1,
                          column=0,
                          columnspan=3,
                          padx=padx,
                          pady=pady,
                          sticky='nsew')
        right_frame.columnconfigure(1, weight=1)
        right_frame.rowconfigure(1, weight=1)
        #
        focus = self.createButtons(bottom_frame, kw)
        # set the scale factor
        self.preview.canvas.preview = 2
        # create a preview of the current game
        self.preview_key = -1
        self.preview_game = None
        self.preview_app = None
        self.updatePreview(gameid, animations=0)
        # focus = self.tree.frame
        self.mainloop(focus, kw.timeout, geometry=geometry)
Esempio n. 19
0
def create_widgets():
    global list_box, canvas, label, zoom_label
    #
    root = tkinter.Tk()
    #
    list_box = tkinter.Listbox(root, exportselection=False)
    list_box.grid(row=0, column=0, rowspan=2, sticky=tkinter.NS)
    cardsets_list = list(cardsets_dict)
    cardsets_list.sort()
    for cs in cardsets_list:
        list_box.insert(tkinter.END, cs)
    list_box.bind('<<ListboxSelect>>', show_cardset)
    #
    sb = tkinter.Scrollbar(root)
    sb.grid(row=0, column=1, rowspan=2, sticky=tkinter.NS)
    list_box.config(yscrollcommand=sb.set)
    sb.config(command=list_box.yview)
    #
    canvas = tkinter.Canvas(root, bg='#5eab6b')
    canvas.grid(row=0, column=2, sticky=tkinter.NSEW)
    canvas.bind('<4>', lambda e: canvas.yview_scroll(-5, 'unit'))
    canvas.bind('<5>', lambda e: canvas.yview_scroll(5, 'unit'))
    #
    sb = tkinter.Scrollbar(root)
    sb.grid(row=0, column=3, sticky=tkinter.NS)
    canvas.config(yscrollcommand=sb.set)
    sb.config(command=canvas.yview)
    #
    if True:
        sb = tkinter.Scrollbar(root, orient=tkinter.HORIZONTAL)
        sb.grid(row=1, column=2, sticky=tkinter.EW)
        canvas.config(xscrollcommand=sb.set)
        sb.config(command=canvas.xview)
    #
    label = tkinter.Label(root)
    label.grid(row=2, column=0, columnspan=4)
    #
    b_frame = tkinter.Frame(root)
    b_frame.grid(row=3, column=0, columnspan=4, sticky=tkinter.EW)
    button = tkinter.Button(b_frame, text='Quit', command=root.quit, width=8)
    button.pack(side=tkinter.RIGHT)
    button = tkinter.Button(b_frame, text='Info', command=show_info, width=8)
    button.pack(side=tkinter.RIGHT)
    if Image:
        global rotate_var, filter_var
        rotate_var = tkinter.IntVar(root)
        filter_var = tkinter.StringVar(root)
        button = tkinter.Button(b_frame, text='  +  ', command=zoom_in)
        button.pack(side=tkinter.LEFT)
        button = tkinter.Button(b_frame, text='  -  ', command=zoom_out)
        button.pack(side=tkinter.LEFT)
        button = tkinter.Button(b_frame, text='  =  ', command=zoom_cancel)
        button.pack(side=tkinter.LEFT)
        button = tkinter.Checkbutton(b_frame,
                                     text='Rotate',
                                     indicatoron=0,
                                     selectcolor=b_frame['bg'],
                                     width=8,
                                     variable=rotate_var,
                                     command=show_cardset)
        button.pack(side=tkinter.LEFT, fill='y')
        om = tkinter.OptionMenu(b_frame,
                                filter_var,
                                'NEAREST',
                                'BILINEAR',
                                'BICUBIC',
                                'ANTIALIAS',
                                command=show_cardset)
        filter_var.set('NEAREST')
        om.pack(side=tkinter.LEFT, fill='y')

        zoom_label = tkinter.Label(b_frame)
        zoom_label.pack(side=tkinter.LEFT)
    #
    root.columnconfigure(2, weight=1)
    root.rowconfigure(0, weight=1)

    root.title('Show Cardsets')

    return root
Esempio n. 20
0
    def __init__(self, parent, title, app, manager, key=None, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)
        #
        if key is None:
            key = manager.getSelected()
        self.manager = manager
        self.key = key
        self.app = app
        self.cardset_values = None
        # padx, pady = kw.padx, kw.pady
        padx, pady = 4, 4
        if self.TreeDataHolder_Class.data is None:
            self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key)
        #
        sw = self.top.winfo_screenwidth()
        sh = self.top.winfo_screenheight()

        h = int(sh * .8)
        w = int(sw * .8)
        w1 = int(min(275, sw / 2.5))
        geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2))
        self.top.wm_minsize(400, 200)

        paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
        paned_window.pack(expand=True, fill='both', padx=8, pady=8)
        left_frame = ttk.Frame(paned_window)
        right_frame = ttk.Frame(paned_window)
        paned_window.add(left_frame)
        paned_window.add(right_frame)

        notebook = ttk.Notebook(left_frame)
        notebook.grid(row=0, column=0, sticky='nsew', padx=padx, pady=pady)
        tree_frame = ttk.Frame(notebook)
        notebook.add(tree_frame, text=_('Tree View'))
        search_frame = ttk.Frame(notebook)
        notebook.add(search_frame, text=_('Search'))

        # Tree
        font = app.getFont("default")
        self.tree = self.Tree_Class(self,
                                    tree_frame,
                                    key=key,
                                    default=kw.default,
                                    font=font,
                                    width=w1)
        self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')

        # Search
        searchText = tkinter.StringVar()
        self.list_searchlabel = tkinter.Label(search_frame,
                                              text="Search:",
                                              justify='left',
                                              anchor='w')
        self.list_searchlabel.pack(side="top", fill='both', ipadx=1)
        self.list_searchtext = tkinter.Entry(search_frame,
                                             textvariable=searchText)
        self.list_searchtext.pack(side="top",
                                  fill='both',
                                  padx=padx,
                                  pady=pady,
                                  ipadx=1)
        searchText.trace('w', self.performSearch)

        self.list_scrollbar = tkinter.Scrollbar(search_frame)
        self.list_scrollbar.pack(side="right", fill='both')

        self.createBitmaps(search_frame, kw)
        self.list = tkinter.Listbox(search_frame, exportselection=False)
        self.list.pack(padx=padx,
                       pady=pady,
                       expand=True,
                       side='left',
                       fill='both',
                       ipadx=1)
        self.updateSearchList("")
        bind(self.list, '<<ListboxSelect>>', self.selectSearchResult)
        bind(self.list, '<FocusOut>',
             lambda e: self.list.selection_clear(0, 'end'))

        self.list.config(yscrollcommand=self.list_scrollbar.set)
        self.list_scrollbar.config(command=self.list.yview)

        if USE_PIL:
            #
            var = tkinter.DoubleVar()
            var.set(app.opt.scale_x)
            self.scale_x = PysolScale(left_frame,
                                      label=_('Scale X:'),
                                      from_=0.5,
                                      to=4.0,
                                      resolution=0.1,
                                      orient='horizontal',
                                      variable=var,
                                      value=app.opt.scale_x,
                                      command=self._updateScale)
            self.scale_x.grid(row=1,
                              column=0,
                              sticky='ew',
                              padx=padx,
                              pady=pady)
            #
            var = tkinter.DoubleVar()
            var.set(app.opt.scale_y)
            self.scale_y = PysolScale(left_frame,
                                      label=_('Scale Y:'),
                                      from_=0.5,
                                      to=4.0,
                                      resolution=0.1,
                                      orient='horizontal',
                                      variable=var,
                                      value=app.opt.scale_y,
                                      command=self._updateScale)
            self.scale_y.grid(row=2,
                              column=0,
                              sticky='ew',
                              padx=padx,
                              pady=pady)
            #
            # sliders at new position
            cs = self.manager.get(self.tree.selection_key)

            var = tkinter.IntVar()
            self.x_offset = PysolScale(left_frame,
                                       label=_('X offset:'),
                                       from_=5,
                                       to=100,
                                       resolution=1,
                                       orient='horizontal',
                                       variable=var,
                                       value=cs.CARD_XOFFSET)

            self.x_offset.grid(row=3,
                               column=0,
                               sticky='ew',
                               padx=padx,
                               pady=pady)

            var = tkinter.IntVar()
            self.y_offset = PysolScale(left_frame,
                                       label=_('Y offset:'),
                                       from_=5,
                                       to=100,
                                       resolution=1,
                                       orient='horizontal',
                                       variable=var,
                                       value=cs.CARD_YOFFSET)
            self.y_offset.grid(row=4,
                               column=0,
                               sticky='ew',
                               padx=padx,
                               pady=pady)

            self.auto_scale = tkinter.BooleanVar()
            self.auto_scale.set(app.opt.auto_scale)
            check = ttk.Checkbutton(left_frame,
                                    text=_('Auto scaling'),
                                    variable=self.auto_scale,
                                    takefocus=False,
                                    command=self._updateAutoScale)
            check.grid(row=5,
                       column=0,
                       columnspan=2,
                       sticky='ew',
                       padx=padx,
                       pady=pady)
            #
            self.preserve_aspect = tkinter.BooleanVar()
            self.preserve_aspect.set(app.opt.preserve_aspect_ratio)
            self.aspect_check = ttk.Checkbutton(
                left_frame,
                text=_('Preserve aspect ratio'),
                variable=self.preserve_aspect,
                takefocus=False,
                # command=self._updateScale
            )
            self.aspect_check.grid(row=6,
                                   column=0,
                                   sticky='ew',
                                   padx=padx,
                                   pady=pady)

            self._updateAutoScale()

        #
        left_frame.rowconfigure(0, weight=1)
        left_frame.columnconfigure(0, weight=1)
        #
        self.preview = MfxScrolledCanvas(right_frame)
        self.preview.setTile(app, app.tabletile_index, force=True)
        self.preview.pack(fill='both', expand=True, padx=padx, pady=pady)
        self.preview.canvas.preview = 1
        # create a preview of the current state
        self.preview_key = -1
        self.preview_images = []
        self.scale_images = []
        self.updatePreview(key)
        #
        focus = self.createButtons(bottom_frame, kw)
        focus = self.tree.frame
        self.mainloop(focus, kw.timeout, geometry=geometry)