Пример #1
0
    def __init__(self, cfg):
        # run Tk
        self.root = tk.Tk()

        self.cfg = cfg

        # create menus
        self.menubar = tk.Menu(self.root)

        self.connection_menu = tk.Menu(self.menubar, tearoff=False)

        self.menubar.add_cascade(label='Settings', menu=self.connection_menu)

        self.menubar.add_command(label="Quit!", command=self.root.quit)

        self.root.config(menu=self.menubar)

        # main window tree view, populate connection menu
        self.tree_widget = TreeWidget(self.root)
        self.tree_widget.grid(sticky='nsew')

        self.set_display_columns()

        self.connection_menu.add_command(label="New connection",
                                         command=self.new_connection)

        self.ss = SwitcherSubmenu(self.connection_menu, self)
        self.ss.populate()

        self.connection_menu.add_command(label="Preferences",
                                         command=self.open_preferences)

        # layout
        self.root.rowconfigure(0, weight=1)
        self.root.columnconfigure(0, weight=1)
Пример #2
0
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    _focus = windowing.FocusManager()
    window = Tk.Tk()
    window.withdraw()

    if Tk.TkVersion >= 8.5:
        # put a mpl icon on the window rather than the default tk icon. Tkinter
        # doesn't allow colour icons on linux systems, but tk >=8.5 has a iconphoto
        # command which we call directly. Source:
        # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
        icon_fname = os.path.join(rcParams['datapath'], 'images',
                                  'matplotlib.ppm')
        icon_img = Tk.PhotoImage(file=icon_fname)
        try:
            window.tk.call('wm', 'iconphoto', window._w, icon_img)
        except (SystemExit, KeyboardInterrupt):
            # re-raise exit type Exceptions
            raise
        except:
            # log the failure, but carry on
            verbose.report('Could not load matplotlib icon: %s' %
                           sys.exc_info()[1])

    canvas = FigureCanvasTkAgg(figure, master=window)
    figManager = FigureManagerTkAgg(canvas, num, window)
    if matplotlib.is_interactive():
        figManager.show()
        canvas.draw_idle()
    return figManager
Пример #3
0
def two_canvas_class_test1():
  """ test the simple display of a static graphic with Two_Canvas
  """
  #
  test_parameter_info = """
Maître Corbeau, sur un arbre perché,
Tenait en son bec un fromage.
Maître Renard, par l'odeur alléché,
Lui tint à peu près ce langage :
"Hé ! bonjour, Monsieur du Corbeau.
Que vous êtes joli ! que vous me semblez beau !
Sans mentir, si votre ramage
Se rapporte à votre plumage,
Vous êtes le Phénix des hôtes de ces bois. "
  """
  #
  #lambda_function_1 = test1_curve1
  #lambda_function_1 = lambda x: test1_curve1(x)
  #lambda_function_2 = test1_curve2
  test1_curve1 = (1,2,3,4,5,6,7,8,9,10,11,12,13)
  test1_curve2 = (8,7,3,4,2,2,3,4,5,5.5,6,6.2,6.9)
  test_curve_graphic_1 = (('global_title', 'x_axis_name', 1),
    ('plot1_title', test1_curve1, 'bo'),
    ('plot2_title', test1_curve2, 'r'))
  #
  tk_root = tkinter.Tk()
  dut = Two_Canvas(tk_root)
  #dut = Two_Canvas()
  dut.add_canvas_graphic_function(test_canvas_graphic_1)
  dut.add_parameter_info(test_parameter_info)
  dut.add_curve_graphic_table(test_curve_graphic_1)
  tk_root.mainloop()
  #dut.mainloop()
  r_test = 1
  return(r_test)
Пример #4
0
    def test_scan(self):
        import twain
        root = tkinter.Tk()
        root.title('scan.py')
        logger.info('creating source manager')
        sm = twain.SourceManager(root)
        logger.info('opening source')
        ss = sm.open_source()  # this posts a modeless dialog...
        logger.info('request acquire')
        ss.request_acquire(show_ui=False, modal_ui=True)
        handles = []
        more = 1
        try:
            logger.info('transferring image')
            handle, more = ss.xfer_image_natively()
            handles.append(handle)
        except twain.excDSTransferCancelled:
            logger.info('cancelled')
            pass
        while more != 0:
            try:
                logger.info('transferring image')
                handle, more = ss.xfer_image_natively()
                handles.append(handle)
            except twain.excDSTransferCancelled:
                logger.info('cancelled')
                more = 0

        logger.info('transfer complete')
        index = 0
        curr_folder = os.path.dirname(__name__)
        for handle in handles:
            twain.dib_to_bm_file(handle, os.path.join(curr_folder, "{}.bmp".format(index)))
            twain.global_handle_free(handle)
            index += 1
Пример #5
0
def init(shouldHalt):
    root = tk.Tk() # Build the Tkinter application
    with TypeDB.core_client("localhost:1729") as client:
        with client.session("tube_network", SessionType.DATA) as session:
            tube_gui = TubeGui(session, root)
            if shouldHalt:
                root.mainloop()
Пример #6
0
    def new_figure_manager_given_figure(num, figure):
        """
        Create a new figure manager instance for the given figure.
        """
        _focus = windowing.FocusManager()
        window = Tk.Tk(className="matplotlib")
        window.withdraw()

        # Put a mpl icon on the window rather than the default tk icon.
        # Tkinter doesn't allow colour icons on linux systems, but tk>=8.5 has
        # a iconphoto command which we call directly. Source:
        # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
        icon_fname = os.path.join(rcParams['datapath'], 'images',
                                  'matplotlib.ppm')
        icon_img = Tk.PhotoImage(file=icon_fname)
        try:
            window.tk.call('wm', 'foobar', window._w, icon_img)
        except Exception as exc:
            # log the failure (due e.g. to Tk version), but carry on
            verbose.report('Could not load matplotlib icon: %s' % exc)

        canvas = FigureCanvasTkAgg(figure, master=window)
        manager = FigureManagerTkAgg(canvas, num, window)
        if matplotlib.is_interactive():
            manager.show()
            canvas.draw_idle()
        return manager
Пример #7
0
    def _showNorm(self):
        """
      Shows normalized data in a separate window.
    """

        if self._normalizedDataShown:
            return

        self._normwin = tk.Tk()
        self._normwin.wm_title("Normalized spectrum")
        self._normwin.protocol("WM_DELETE_WINDOW", self._quitWin)

        # A frame containing the mpl plot
        self.normFrame = tk.Frame(master=self._normwin)
        self.normFrame.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
        self.normCanvas = FigureCanvasTkAgg(self.normf, master=self.normFrame)

        # a tk.DrawingArea
        self.normCanvas.get_tk_widget().pack()
        self.normToolbar = NavigationToolbar2TkAgg(self.normCanvas,
                                                   self.normFrame)
        self.normToolbar.update()
        self.normCanvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        closeButton = tk.Button(master=self._normwin,
                                text='Close',
                                command=self._quitWin)
        closeButton.pack(side=tk.BOTTOM)

        self._normalizedDataShown = True
        self._updateNormalizationPlot()
Пример #8
0
    def main(self):
        """ Run main application """
        self.main_tk = Tk.Tk()
        self.main_tk.title('Trakt.tv Playback Progress Remover')
        set_icon(self.main_tk)

        self.busyman = BusyManager(self.main_tk)

        self.main_win = MainScreen(self.main_tk, self)
        center_toplevel(self.main_tk)

        auth_opened = self.show_auth_window()

        self.busyman.busy()

        if self.authorization and not auth_opened:
            try:
                self.update_user_info(raise_on_error=True)
                self.refresh_list(raise_on_error=True)
            except auth.NotAuthenticatedError:
                self._authorization = None
                auth.remove(self.auth_filepath)
                self.main_win.toggle_auth_button(True)
                self.main_win.lbl_loggedin.set('Not logged in.')
                tk_messagebox.showwarning('Error', 'Authentication required.')

        self.busyman.unbusy()

        self.main_tk.mainloop()
Пример #9
0
def init(shouldHalt):
    root = tk.Tk()  # Build the Tkinter application
    with GraknClient(uri="localhost:48555") as client:
        with client.session(keyspace="tube_network") as session:
            tube_gui = TubeGui(session, root)
            if shouldHalt:
                root.mainloop()
Пример #10
0
def progressbar_main(args):
    from pysollib.ui.tktile.tkutil import wm_withdraw
    tk = tkinter.Tk()
    wm_withdraw(tk)
    TestProgressBar(tk)
    tk.mainloop()
    return 0
Пример #11
0
 def __init__(self):
     # create window
     self.root = tk.Tk()
     self.root.title("Mandelbrot Set")
     self.create_image()
     self.create_label()
     # start event loop
     self.root.mainloop()
Пример #12
0
 def configure_subplots(self):
     toolfig = Figure(figsize=(6, 3))
     window = Tk.Tk()
     canvas = FigureCanvasTkAgg(toolfig, master=window)
     toolfig.subplots_adjust(top=0.9)
     tool = SubplotTool(self.canvas.figure, toolfig)
     canvas.show()
     canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
Пример #13
0
def test(aggimage):
    r = Tk.Tk()
    c = Tk.Canvas(r, width=aggimage.width, height=aggimage.height)
    c.pack()
    p = Tk.PhotoImage(width=aggimage.width, height=aggimage.height)
    blit(p, aggimage)
    c.create_image(aggimage.width,aggimage.height,image=p)
    blit(p, aggimage)
    while True: r.update_idletasks()
Пример #14
0
 def __init__(self, options, preload=True):
     self.fields = {}
     self.responses = {}
     self.root = tk.Tk()
     self.row = 0
     if preload:
         self._GuiHeader()
         self._LoadOptions(options)
         self._GuiFooter()
Пример #15
0
def playeroptionsdialog_main(args):
    from pysollib.ui.tktile.tkutil import wm_withdraw
    opt = Struct(player="Test", update_player_stats=1)
    app = Struct(opt=opt)
    tk = tkinter.Tk()
    wm_withdraw(tk)
    tk.update()
    d = PlayerOptionsDialog(tk, "Player options", app)
    print(d.status, d.button, ":", d.player, d.update_stats)
    return 0
Пример #16
0
 def test_dsm(self):
     import twain
     root = tkinter.Tk()
     root.title('scan.py')
     with twain.SourceManager(root) as sm:
         if len(sm.source_list) == 0:
             self.skipTest('No Sources present on the system')
         ds_name = sm.source_list[0]
         with sm.open_source(str(ds_name)) as ds:
             pass
Пример #17
0
def application(cfg, connection_name, path):
    """
    Executes the Brocoli application
    """
    def new_connection():
        dialog = preferences.ConnectionConfigDialog(root)

        if dialog.result is None:
            return

        config.save_config(dialog.to_config_dict(), update=True)
        ss.cfg = config.load_config()
        ss.populate()

    def open_preferences():
        prefs = preferences.Preferences(root)
        if prefs.changed:
            ss.cfg = prefs.connection_manager.cfg
            ss.populate()

    # run Tk
    root = tk.Tk()

    # get connection
    cat, root_path = cfg.connection(connection_name)

    # main window tree view
    app = TreeWidget(root, cat, path=path or root_path)

    # create menus
    menubar = tk.Menu(root)

    connection_menu = tk.Menu(menubar, tearoff=False)

    connection_menu.add_command(label="New connection", command=new_connection)
    switch_menu = None

    ss = SwitcherSubmenu(cfg, connection_menu, app)
    ss.populate()

    connection_menu.add_command(label="Preferences", command=open_preferences)
    menubar.add_cascade(label='Settings', menu=connection_menu)

    menubar.add_command(label="Quit!", command=root.quit)

    root.config(menu=menubar)

    # layout
    root.rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)

    # event loop
    root.mainloop()
Пример #18
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
Пример #19
0
def tkhtml_main(args):
    try:
        url = args[1]
    except:
        url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
    top = tkinter.Tk()
    top.wm_minsize(400, 200)
    viewer = HTMLViewer(top)
    viewer.app = None
    viewer.display(url)
    top.mainloop()
    return 0
Пример #20
0
    def init_window(self):
        if self.window:
            return

        toolfig = Figure(figsize=(6, 3))
        self.window = Tk.Tk()

        canvas = FigureCanvasTkAgg(toolfig, master=self.window)
        toolfig.subplots_adjust(top=0.9)
        _tool = SubplotTool(self.figure, toolfig)
        canvas.show()
        canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self.window.protocol("WM_DELETE_WINDOW", self.destroy)
Пример #21
0
 def test_dsm(self):
     import twain
     root = tkinter.Tk()
     root.title('scan.py')
     with twain.SourceManager(root) as sm:
         if len(sm.source_list) == 0:
             self.skipTest('No Sources present on the system')
         ds_name = sm.source_list[0]
         with sm.open_source(str(ds_name)) as ds:
             val = ds.get_capability(twain.ICAP_YRESOLUTION)
             print(val)
             for v in val[1][2]:
                 print(v)
Пример #22
0
    def __init__(self):
        ModelNode.__init__(node_name=Scripting.root_name, is_root=True)
        tk_root = tkinter.Tk()
        tk_root.widthdraw()

        with self.attribute_lock:
            set_attributes(
                self,
                # UI elements
                tk_root=tk_root,
                value_checker=ValueChecker(tk_root),
                balloon=tix.Balloon(tk_root)
                # End UI elements
            )
Пример #23
0
    def _showList(self):
        """
        Creates a new window containing a copy-and-paste aware list of the points.
      """
        def _quitWin():
            win.destroy()

        win = tk.Tk()
        text = tk.Text(master=win)
        text.pack()
        for p in self.pointList:
            text.insert(tk.END, p.asStr() + "\n")
        quit = tk.Button(master=win, text='Quit', command=_quitWin)
        quit.pack()
        win.wm_title("Copy Window")
Пример #24
0
def make_app(frame_cls, *args, **kwargs):
    """Make a simple tkinter application from a single Frame.

  A utility function that wraps a single tkinter Frame into its own
  application.

  Args:
    frame_cls (tkinter.Frame): Frame class
    *args: Argument list to initialize `frame_cls`
    **kwargs: Keyword arguments to initialize `frame_cls`
  """
    toplevel = tkinter.Tk()
    frame = frame_cls(*args, master=toplevel, **kwargs)
    frame.pack(fill='both', expand=True)
    toplevel.mainloop()
Пример #25
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
Пример #26
0
    def __init__(self, callback=None, numSamples=1):
        # Initialize tkinter
        self.root = tk.Tk()
        self.canvas = tk.Canvas(width=WIDTH, height=HEIGHT)
        self.canvas.bind('<Button-1>', self.down)
        self.canvas.bind('<ButtonRelease-1>', self.up)
        self.canvas.bind('<B1-Motion>', self.update)
        self.canvas.pack()

        if callback is None:
            self.callback = print
        else:
            self.callback = callback

        self.numSamples = numSamples
        self.points = None
        self.root.mainloop()
Пример #27
0
def get_dir():
    """
    GUI popup for directory selection.

    Defaults to text input if Tkinter isn't available.
    """
    if USE_TK:
        window = tkinter.Tk()
        window.withdraw()
        target_dir = askdirectory()
        window.destroy()
        return os.path.normpath(target_dir)
    else:
        path = input('Enter path:')
        target_dir = os.path.abspath(path)
        if not os.path.isdir():
            raise Exception('Path is not a valid directory.')
        return target_dir
Пример #28
0
    def run(self):
        self.root = tkinter.Tk()
        if self.geometry is None:
            root_geometry = '900x510'
        else:
            root_geometry = str(self.geometry[0]) + 'x' + str(self.geometry[1])
        # put the root window in some sensible position
        self.root.geometry(root_geometry + '+40+40')

        self.app = TkApplication(master=self.root,
                                 address=self.address,
                                 controller_address=self.controller_address,
                                 geometry=self.geometry,
                                 delay=self.delay)
        # schedule next read
        self.root.after_idle(self.app.read_queue)
        try:
            self.root.mainloop()
        except KeyboardInterrupt:
            pass
Пример #29
0
def main(argv=None):
    parser = argparse.ArgumentParser(
        description="Tkinter interface for PINT pulsar timing tool"
    )
    parser.add_argument("parfile", help="parfile to use")
    parser.add_argument("timfile", help="timfile to use")
    parser.add_argument("--ephem", help="Ephemeris to use", default=None)
    parser.add_argument(
        "--test",
        help="Build UI and exit. Just for unit testing...",
        default=False,
        action="store_true",
    )
    args = parser.parse_args(argv)

    root = tk.Tk()
    if not args.test:
        app = PINTk(root, parfile=args.parfile, timfile=args.timfile, ephem=args.ephem)
        root.protocol("WM_DELETE_WINDOW", root.destroy)
        root.mainloop()
Пример #30
0
    def __init__(self, input_file, args_level, args_backend, args_display_view):
        """
        Constructor initializes the tkinter display with the IsyntaxFilePath.
        :param input_file: IsyntaxFilePath
        :param args_level: The requested level
        :param args_backend: The requested backend option
        """
        self._mouse_wheel_down, self._mouse_wheel_up = Constants.get_mouse_wheel()
        self._window = tk.Tk()
        if args_display_view:
            self._title = "Python iSyntax Viewer                File: {}                View: " \
                          "Display ".format(input_file)
        else:
            self._title = "Python iSyntax Viewer                File: {}                View: " \
                          "Source ".format(input_file)
        self._window.title(self._title)
        # Configuring self.windows geometry as primary monitors height and width
        self._window.geometry("{}x{}+200+100".format(str(self._window.winfo_screenwidth()),
                                                     str(self._window.winfo_screenheight())))
        self._canvas = tk.Canvas(self._window, background='black')
        
        self._canvas.pack(side='left', expand='yes', fill='both')

        self.menu = tk.Menu(self._window)
        self.menu.add_command(label="Thumbnail", command=self.show_macro_label_image)
        self.menu.add_command(label="Properties", command=self.show_properties)
        self._process_tiles = TileProcessor(input_file, args_level, args_backend, args_display_view)
        self.display_canvas()
        self.register_mouse_events()
        self._window.config(menu=self.menu)
        self._window.mainloop()  # Event processing loop
        self.macro_image_data = None
        self.label_image_data = None

        
        ######
        
        self.start=(0,0)
        self.end=(0,0)