Beispiel #1
0
def blit(photoimage, aggimage, bbox=None, colormode=1):
    tk = photoimage.tk

    if bbox is not None:
        bbox_array = bbox.__array__()
        # x1, x2, y1, y2
        bboxptr = (bbox_array[0, 0], bbox_array[1, 0], bbox_array[0, 1],
                   bbox_array[1, 1])
    else:
        bboxptr = 0
    data = np.asarray(aggimage)
    dataptr = (data.shape[0], data.shape[1], data.ctypes.data)
    try:
        tk.call("PyAggImagePhoto", photoimage, dataptr, colormode, bboxptr)
    except tk.TclError:
        if hasattr(tk, 'interpaddr'):
            _tkagg.tkinit(tk.interpaddr(), 1)
        else:
            # very old python?
            _tkagg.tkinit(tk, 0)
        tk.call("PyAggImagePhoto", photoimage, dataptr, colormode, bboxptr)
Beispiel #2
0
def blit(photoimage, aggimage, bbox=None, colormode=1):
    tk = photoimage.tk

    if bbox is not None:
        bbox_array = bbox.__array__()
        # x1, x2, y1, y2
        bboxptr = (bbox_array[0, 0], bbox_array[1, 0],
                   bbox_array[0, 1], bbox_array[1, 1])
    else:
        bboxptr = 0
    data = np.asarray(aggimage)
    dataptr = (data.shape[0], data.shape[1], data.ctypes.data)
    try:
        tk.call(
            "PyAggImagePhoto", photoimage,
            dataptr, colormode, bboxptr)
    except tk.TclError:
        if hasattr(tk, 'interpaddr'):
            _tkagg.tkinit(tk.interpaddr(), 1)
        else:
            # very old python?
            _tkagg.tkinit(tk, 0)
        tk.call("PyAggImagePhoto", photoimage,
                dataptr, colormode, bboxptr)
Beispiel #3
0
def fixwordbreaks(root):
    # Copied from idlelib.EditorWindow (Python 3.4.2)
    # Modified to include non-ascii chars

    # Make sure that Tk's double-click and next/previous word
    # operations use our definition of a word (i.e. an identifier)
    tk = root.tk
    tk.call("tcl_wordBreakAfter", "a b", 0)  # make sure word.tcl is loaded
    tk.call("set", "tcl_wordchars", "[a-zA-Z0-9_À-ÖØ-öø-ÿĀ-ſƀ-ɏА-я]")
    tk.call("set", "tcl_nonwordchars", "[^a-zA-Z0-9_À-ÖØ-öø-ÿĀ-ſƀ-ɏА-я]")
Beispiel #4
0
def fixwordbreaks(root):
    # Adapted from idlelib.EditorWindow (Python 3.4.2)
    # Modified to include non-ascii chars

    # Make sure that Tk's double-click and next/previous word
    # operations use our definition of a word (i.e. an identifier)
    tk = root.tk
    tk.call('tcl_wordBreakAfter', 'a b', 0)  # make sure word.tcl is loaded
    tk.call('set', 'tcl_wordchars', u'[a-zA-Z0-9_À-ÖØ-öø-ÿĀ-ſƀ-ɏА-я]')
    tk.call('set', 'tcl_nonwordchars', u'[^a-zA-Z0-9_À-ÖØ-öø-ÿĀ-ſƀ-ɏА-я]')
Beispiel #5
0
    def createWidgets(self):
        """ Creates and lays out the widgets for the mainwindow."""
        # create Menus:
        self.menubar = tk.Menu(self.mainframe)
        filemenu = tk.Menu(self.menubar, tearoff=0)
        mnuimport = tk.Menu(filemenu, tearoff=0)
        mnuimport.add_command(label="Target list", command=self._file_menu_import_target_list)
        mnuimport.add_command(label="Switch list", command=self._file_menu_import_switch_list)
        filemenu.add_command(label="New search", command=self._file_menu_new_search, underline=1)
        filemenu.add_cascade(label="Import", menu=mnuimport)
        filemenu.add_separator()
        filemenu.add_command(label="Settings", command=self._file_menu_settings, underline=0)
        filemenu.add_command(label="Exit", command=self.quit, underline=1, accelerator="Ctrl+X")
        #--end-- File menu build

        #--start-- edit menu build
        editmenu = Menu(self.menubar, tearoff=0)
        editmenu.add_command(label="Add target(s)", underline=4, accelerator="Ctrl-T", command=self._edit_menu_add_target_to_list)
        editmenu.add_command(label="Edit selected target", command=self._edit_menu_edit_selected_target)
        editmenu.add_command(label="Delete selected target", command=self._edit_menu_del_selected_target)
        editmenu.add_separator()
        editmenu.add_command(label="Add host(s)", underline=4, accelerator="Ctrl-H", command=self._edit_menu_add_host_to_list)
        editmenu.add_command(label="Edit selected host", command=self._edit_menu_edit_selected_host)
        editmenu.add_command(label="Delete selected host", command=self._edit_menu_del_selected_host)
        editmenu.add_separator()
        editmenu.add_command(label="Clear log window", command=self.logg.clear)
        #--end-- edit menu build

        #--start-- view menu
        viewmenu = Menu(self.menubar, tearoff=0)
        viewmenu.add_checkbutton(label="Show/hide Logg", onvalue=True, offvalue=False, variable=self.viewlogg, command=self._viewmenu_show_window_pane)
        #--end-- viewmenu
        
        #--start-- help menu build
        hlpmenu = tk.Menu(self.menubar, tearoff=0)
        hlpmenu.add_command(label="Help", command=self._help_menu_help)
        hlpmenu.add_command(label="About", command=self._help_menu_about)
        #--end-- help menu build
        
        #--start-- adding menus to main menu
        self.menubar.add_cascade(label="File", menu=filemenu)
        self.menubar.add_cascade(label="Edit", menu=editmenu)
        self.menubar.add_cascade(label="View", menu=viewmenu)
        self.menubar.add_cascade(label="Help", menu=hlpmenu)
        #--end-- adding menus to main menu
        try:
            self.config(menu=self.menubar)
        except AttributeError:
            print("this faild!!!!")
            # master is a toplevel window (Python 1.4/Tkinter 1.63)
            tk.call(self, "config", "-menu", self.menubar)

        #create Toolbar
        toolbar = Toolbar(parent=self.mainframe)
        toolbar.add(wtype="button", gfxpath=self.gfxpath + "start.png",
                    tooltip="Start the search", command=self.addtext)
        toolbar.add(wtype="button", gfxpath=self.gfxpath + "new.png",
                    tooltip="Clears all results and start fresh")
        toolbar.add(wtype="separator")
##        toolbar.add(wtype="button", gfxpath=self.gfxpath + "addtarget.png",
##                    tooltip="Add target or a range of targets to targetslist", command=self.list_add)
##        toolbar.add(wtype="button", gfxpath=self.gfxpath + "addhost.png",
##                    tooltip="Add a host or range of hosts to hostslist")
##        toolbar.add(wtype="separator")
        toolbar.add(wtype="button", gfxpath=self.gfxpath + "exit.png",
                    tooltip="Exits the program. (Ctrl-X)", command=self.quit)
        toolbar.show()

        # create Statusbar
        self.status = StringVar()
        self.statusbar = Label(self, textvariable=self.status, bd=1, relief=SUNKEN, anchor=W)
        self.statusbar.pack(side=BOTTOM, fill=X)
        self.status.set("Idle")
        
        #create input boxes:
        self.inputframe = Frame(self.mainframe, width=50, bd=1, relief=GROOVE, padx=12, pady=12)
        Label(self.inputframe, text="Targets to look for:", pady=2).pack()
        self.list_targets = Listbox(self.inputframe, selectmode=BROWSE)
        self.list_targets.pack(side=TOP, pady=5)
        self.listwidgets[self.list_targets.winfo_name] = 'targets'
        self.list_targets_toolbar = Toolbar(parent=self.inputframe)
        self.list_targets_toolbar.add(wtype="button", gfxpath=self.gfxpath + "addtarget.png",
                                      tooltip="Add new target", command=lambda: self.list_add(widget=self.list_targets))
        self.list_targets_toolbar.add(wtype="button", gfxpath=self.gfxpath + "edit.png",
                                      tooltip="Edit selected target", command=lambda: self.edit_item(widget=self.list_targets))
        self.list_targets_toolbar.add(wtype="button", gfxpath=self.gfxpath + "trash.png",
                                      tooltip="Delete selected target", command=lambda: self.delete_item(widget=self.list_targets))
        self.list_targets_toolbar.show()
        Frame(self.inputframe, height=2, bd=1, relief=SUNKEN).pack(fill=X, padx=0, pady=10)
        Label(self.inputframe, text="Hosts to scan:", pady=2).pack()
        self.list_hosts = Listbox(self.inputframe, selectmode=BROWSE)
        self.list_hosts.pack(side=TOP, pady=5)
        self.listwidgets[self.list_hosts.winfo_name] = 'hosts'
        self.list_hosts_toolbar = Toolbar(parent=self.inputframe)
        self.list_hosts_toolbar.add(wtype="button", gfxpath=self.gfxpath + "addhost.png",
                                    tooltip="Add new host", command=lambda: self.list_add(self.list_hosts))
        self.list_hosts_toolbar.add(wtype="button", gfxpath=self.gfxpath + "edit.png",
                                    tooltip="Edit selected host", command=lambda: self.edit_item(widget=self.list_hosts))
        self.list_hosts_toolbar.add(wtype="button", gfxpath=self.gfxpath + "trash.png",
                                    tooltip="Delete selected host", command=lambda: self.delete_item(widget=self.list_hosts))
        self.list_hosts_toolbar.show()
        self.inputframe.pack(side=RIGHT, fill=Y)