예제 #1
0
class UrlSelectColumnFrame(ttk.Frame):
    def __init__(self, master=None, id=None, url='', response_gt=None, max_page=None, is_using=True, **kw):
        super().__init__(master, **kw)
        self.database_id = id
        self.check_button = CheckButton(self, value=is_using, help_text='是否启用')
        self.url_text = UrlEntry(self, width=50, value=url, help_text='url!!!!')
        self.response_num_text = NumberEntry(self, width=5, value=response_gt, help_text='最小相应数')
        self.max_page_text = NumberEntry(self, width=5, value=max_page, help_text='最大搜索页数')
        self.delete_button = Button(self, text='Delete', command=self.delete, help_text='删除')

        self.check_button.grid(column=0, row=0)
        self.url_text.grid(column=1, row=0)
        self.response_num_text.grid(column=2, row=0)
        self.max_page_text.grid(column=3, row=0)
        self.delete_button.grid(column=4, row=0)

        for w in self.children.values():
            w.bind('<Enter>', self.show_help_text)

    def get_as_dict(self):
        ret = {
            'url': self.url_text.get(),
            'response_gt': self.response_num_text.get(),
            'max_page': self.max_page_text.get(),
            'is_using': self.check_button.get(),
            'id': self.database_id,
        }
        return ret

    def info_is_using(self):
        """
        :return: If Checkbutton is pressed
        """
        return True if self.check_button.get() else False

    def delete(self):
        Tasks.delete_by_id(self.database_id)
        self.destroy()

    def show_help_text(self, event):
        help_text = event.widget.help_text
        self.master.set_info(help_text)
예제 #2
0
    def __init__(self, master=None, id=None, url='', response_gt=None, max_page=None, is_using=True, **kw):
        super().__init__(master, **kw)
        self.database_id = id
        self.check_button = CheckButton(self, value=is_using, help_text='是否启用')
        self.url_text = UrlEntry(self, width=50, value=url, help_text='url!!!!')
        self.response_num_text = NumberEntry(self, width=5, value=response_gt, help_text='最小相应数')
        self.max_page_text = NumberEntry(self, width=5, value=max_page, help_text='最大搜索页数')
        self.delete_button = Button(self, text='Delete', command=self.delete, help_text='删除')

        self.check_button.grid(column=0, row=0)
        self.url_text.grid(column=1, row=0)
        self.response_num_text.grid(column=2, row=0)
        self.max_page_text.grid(column=3, row=0)
        self.delete_button.grid(column=4, row=0)

        for w in self.children.values():
            w.bind('<Enter>', self.show_help_text)