Пример #1
0
  def create_widgets(self, base):
    cc = self.cc

  # -- entry
    fr = fr1 = Frame(base).pack(side='top')
    cap = 'エントリ(&E)'
    pos, label = item_caption(cap)
    lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)
    ent = Entry(fr, name='input', width=25).pack(side='left', padx=3, pady=3)
    ent.bind('<Return>', self.bind_proc('input'))
    self.input = 'AAA'
    lab.label_for = ent
    ent.after_idle(lambda wi=ent:entry_focus(wi))

  # -- passwod entry
    fr = Frame(base).pack(side='top')
    cap = 'パスワード(&P)'
    pos, label = item_caption(cap)
    lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)
    
    ent = Entry(fr, name='passwd', show='*', width=25).pack(side='left', padx=3, pady=3)
    ent.bind('<Return>', self.bind_proc('input'))
    self.passwd = 'BBB'
    lab.label_for = ent

  # -- combobox(Edit)
    fr = Frame(base).pack(side='top')
    cap = 'コンボボックス(&B)'
    pos, label = item_caption(cap)
    lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

    ent = Combobox(fr, name='combo', width=25).pack(side='left', padx=3, pady=3)
    ent['values'] = ('AA', 'BB', 'CC')
    ent.current(1)
    self.combo = 'CCC'
    lab.label_for = ent
    
    ent.bind('<<ComboboxSelected>>', self.bind_proc('combo'))
    ent.bind('<Return>', self.bind_proc('combo'))
    ent.bind('<Control-j>', self.bind_proc('combo'))

  # -- readonly text
    ent = Entry(base, name='message', width=25, takefocus=0, state='readonly',
                style='TLabel').pack(side='top', padx=3, pady=3, before=fr1)
    self.message = 'Uneditable Text'
    
  # -- button
    fr = Frame(base).pack(side='top')
    cap = 'ボタン(&A)'
    pos, label = item_caption(cap)
    btn = Button(fr, text=label, underline=pos,
                 command=self.menu_proc('apply')).pack(side='left', padx=3, pady=3)

    cap = 'close'
    pos, label = item_caption(cap)
    btn = Button(fr, text=label, underline=pos, command=self.menu_proc('close'))
    btn.pack(side='left', padx=3, pady=3)
    cc.bind('<Escape>', lambda ev, wi=btn: wi.invoke())
Пример #2
0
    def __init__(self, master=None, mon=None, year=None):
        Frame.__init__(self, master)
        self.cell = None
        self.base = None
        now = _dt.now()
        if not mon: mon = now.month
        if not year: year = now.year

        var = StringVar()
        self.caption = var
        var.set('%s-%s' % (year, mon))
        cap = Label(self, textvariable=var).pack(side='top')
        tbl = self.table = Treeview(self,
                                    takefocus=1,
                                    height=6,
                                    show='headings',
                                    selectmode='none')
        tbl.pack(side='top')

        week = ('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa')
        tbl['columns'] = week

        for wn in week:
            tbl.heading(wn, text=wn)
            tbl.column(wn, width=30, anchor='center')

        var = StringVar()
        cell = ui.tk.Label(tbl, textvariable=var, anchor='center', bg='orange')
        cell.var = var
        cell.timer = None
        cell.info = None
        self.cell = cell
        self.reset_days(mon, year)

        for cond, proc in (
            ('<Button-1>', self._select_day),
            ('<FocusIn>', lambda ev: self._update_cell()),
            ('<FocusOut>', lambda ev: self.cell.place_forget()),
            ('<Configure>', self._resize_notify),
            ('<Double-1>', self.pickup_day),
            ('<Up>', lambda ev, key='up': self._key_action(ev, key)),
            ('<Down>', lambda ev, key='down': self._key_action(ev, key)),
            ('<Left>', lambda ev, key='left': self._key_action(ev, key)),
            ('<Right>', lambda ev, key='right': self._key_action(ev, key)),
            ('<End>', lambda ev, key='end': self._key_action(ev, key)),
            ('<Home>', lambda ev, key='home': self._key_action(ev, key)),
            ('<Control-f>', lambda ev, key='right': self._key_action(ev, key)),
            ('<Control-b>', lambda ev, key='left': self._key_action(ev, key)),
            ('<Control-p>', lambda ev, key='up': self._key_action(ev, key)),
            ('<Control-n>', lambda ev, key='down': self._key_action(ev, key)),
            ('<Control-a>', lambda ev, key='home': self._key_action(ev, key)),
            ('<Control-e>', lambda ev, key='end': self._key_action(ev, key)),
            ('<Return>', self.pickup_day),
        ):
            tbl.bind(cond, proc)
        cell.bind('<Double-1>', self.pickup_day)
        self.ent = None
Пример #3
0
    def create_widgets(self, base):
        """ コンポーネントを作成する """
        cc = self.cc
        fr = Frame(base).pack(side='top')
        cal = _Calendar(fr).pack(side='left')
        cal.base = self
        self.cal1 = cal1 = cal

        (month, year) = cal.next_month()
        cal = _Calendar(fr, month, year).pack(side='left')
        cal.base = self
        self.cal2 = cal

        fr = Frame(base).pack(side='bottom')

        cap = '&Select'
        cap = '選択(&S)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos, command=self._pickup_date)
        btn.pack(side='left', padx=3, pady=3)

        cap = '&Today'
        cap = '今日(&T)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos, command=self._this_month)
        btn.pack(side='left', padx=3, pady=3)

        cap = '&Previous'
        cap = '先月(&P)'
        pos, label = item_caption(cap)
        btn = Button(fr,
                     text=label,
                     underline=pos,
                     command=self._previous_month)
        btn.pack(side='left', padx=3, pady=3)

        cap = '&Next'
        cap = '来月(&N)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos, command=self._next_month)
        btn.pack(side='left', padx=3)

        var = StringVar()
        self.today = var
        now = _dt.now()

        tf = u'today: %s-%s-%s'
        tf = u'今日: %s-%s-%s'

        var.set(tf % (now.year, now.month, now.day))
        cap = Label(fr, textvariable=var).pack(side='left', padx=3)

        cc.bind('<Control-w>', self.close)
        cc.bind('<Escape>', self.close)
        cal1.table.focus_set()
Пример #4
0
    def create_widgets(self, tab):
        rows = 8
        # -- left list
        fr = Frame(tab).pack(side='left', fill='both', expand=1)

        cap = "Source"
        pos, label = item_caption(cap)
        cap = Label(fr, text=label, underline=pos).pack(side='top', padx=3)

        lb = Listbox(fr, height=rows, selectmode=tk.EXTENDED).pack(side='left',
                                                                   fill='both',
                                                                   expand=1)
        lb.bind('<Double-1>', self._left_selected)
        lb.bind('<Return>', self._left_selected)
        ui.setup_theme(lb)

        sb = Scrollbar(fr).pack(side='left', fill='y', expand=0)
        sb.config(command=lb.yview)
        lb.config(yscrollcommand=sb.set)
        for nn in dir(self):
            lb.insert(END, nn)
        self.leftList = lb
        fr = Frame(tab).pack(side='left', fill='y')

        # -- button
        fr = Frame(tab).pack(side='left', fill='y', pady=10, padx=3)
        btn = Button(fr, text='>>',
                     command=self._left_move_all).pack(side='top', pady=3)
        btn = Button(fr, text='<<',
                     command=self._right_move_all).pack(side='top', pady=3)
        btn = Button(fr, text='>',
                     command=self._left_selected).pack(side='top', pady=3)
        btn = Button(fr, text='<',
                     command=self._right_selected).pack(side='top', pady=3)

        # -- right list
        fr = Frame(tab).pack(side='left', fill='both', expand=1)
        cap = "Selected"
        pos, label = item_caption(cap)
        cap = Label(fr, text=label, underline=pos).pack(side='top', padx=3)

        lb = Listbox(fr, height=rows, selectmode=tk.EXTENDED).pack(side='left',
                                                                   fill='both',
                                                                   expand=1)
        lb.bind('<Double-1>', self._right_selected)
        lb.bind('<Return>', self._right_selected)

        sb = Scrollbar(fr).pack(side='left', fill='y', expand=0)
        sb.config(command=lb.yview)
        lb.config(yscrollcommand=sb.set)

        self.rightList = lb
Пример #5
0
    def create_widgets(self, base, rows=15, column=60):
        cc = self.cc
        fr = Frame(base).pack(side='top', fill='both', expand=1)
        sbar = Scrollbar(fr)
        self.buf = buf = tk.Text(fr, width=column, height=rows, padx=5)
        sbar.config(command=buf.yview)
        sbar.pack(side='right', fill='y')
        buf.config(yscrollcommand=sbar.set)
        buf.pack(side='left', fill='both', expand=1)

        for cond, proc in (
                #('<Button>', self._append_event_text),
            ('<ButtonPress>', self._append_event_text),
            ('<ButtonRelease>', self._append_event_text),
            ('<KeyPress>', self._append_event_text),
            ('<KeyRelease>', self._append_event_text),
                #('<Key>', self._append_event_text),
            ('<Control-w>', lambda e, ac=cc: ac.close()),
            ('<Enter>', lambda e, wi=buf: wi.focus_set()),
            ('<MouseWheel>', self._append_event_text),
            ('<Configure>', self._configure_notify),
        ):
            buf.bind(cond, proc)

        #cc.top.bind('<Configure>', self._configure_notify, '+')
        self.timer = None
        shortcut = self.find_menu('eventview-shortcut')
        ui.register_shortcut(buf, shortcut)
        #if ui.need_unpost: shortcut.bind('<FocusOut>', lambda ev, wi=shortcut: wi.unpost())
        buf.insert(INSERT,
                   'platform: %s: %s\n' % (platform.system(), sys.platform))
Пример #6
0
    def create_widgets(self, base):
        cc = self.cc
        cc.find_status_bar()

        if False:
            fr = Frame(base)
            fr.pack(side='top', fill='x')

            cap = '&Tree Editor'
            cap = 'ツリーエディタ(&T)'
            pos, label = item_caption(cap)
            cap = Label(fr, text=label, underline=pos).pack(side='left')

        fr = Frame(base).pack(side='top', fill='both', expand=1)

        tree = Treeview(fr,
                        show='tree',
                        takefocus=True,
                        height=10,
                        selectmode='extended')
        self.tree = tree
        ysb = Scrollbar(fr, orient='vertical', command=tree.yview)
        ysb.pack(side='right', fill='y')
        tree.configure(yscroll=ysb.set)
        tree.pack(side='top', fill='both', expand=1)
        tree.heading('#0', text='Path', anchor='w')

        shortcut = self.find_menu('tree-shortcut')
        ui.register_shortcut(tree, shortcut)

        tree.timer = None
        delay_msec = 600

        def _delay_proc(event):
            # 遅延表示
            if tree.timer: tree.after_cancel(tree.timer)
            tiid = tree.focus()
            if tiid:
                tree.timer = tree.after(
                    delay_msec,
                    lambda wi=tree, iid=tiid: trace(wi.index(iid),
                                                    wi.item(iid, 'text'), iid))

        tree.bind('<<TreeviewSelect>>', _delay_proc)
        tree.bind('<<TreeviewOpen>>', _delay_proc)
        tree.bind('<<TreeviewClose>>', _delay_proc)

        sm = cc.menu['select-mode']
        sm.set('sm.extended')
        self.selection_mode = sm

        self.__test_data(tree)

        for ev, cmd in (
            ('<Control-c>', 'copy'),
            ('<Control-Insert>', 'copy'),
            ('<Control-v>', 'paste'),
            ('<Shift-Insert>', 'paste'),
            ('<Delete>', 'delete-node'),
            ('<F2>', 'rename'),
            ('<Control-w>', 'close'),
            ('<Control-Right>', 'expand-all'),
            ('<Control-Left>', 'collapse-all'),
        ):
            tree.bind(ev, self.bind_proc(cmd))
Пример #7
0
    def create_widgets(self, base):
        """構成コンポーネントの作成"""

        fr = self.cc.find_status_bar()
        nb = Notebook(base).pack(expand=1, fill='both', padx=5, pady=5)
        nb.enable_traversal()
        nb.tno = None
        tno = 0
        tab_bind = {}

        def _tab_changed(event):
            """タブの切り替えで、まとめてバインド"""
            if nb.tno in tab_bind:
                for bk, proc in tab_bind[nb.tno]:
                    self.cc.unbind(bk)
            nb.tno = nb.index('current')
            if nb.tno in tab_bind:
                for bk, proc in tab_bind[nb.tno]:
                    self.cc.bind(bk, proc)

        # タブの切り替えで呼び出される仮想イベント
        nb.bind('<<NotebookTabChanged>>', _tab_changed)

        # -- 基本コンポーネントシート

        tab = Frame(nb).pack(expand=1, fill='both', padx=5, pady=5)
        cap = '&Basic'
        pos, label = item_caption(cap)
        nb.add(tab, text=label, underline=pos)

        self._create_basic_tab(tab)
        if hasattr(tab, 'blist'): tab_bind[tno] = tab.blist
        tno += 1

        # -- ダイアログ呼び出し
        tab = Frame(nb).pack(expand=1, fill='both', padx=5, pady=5)
        cap = '&Dialog'
        pos, label = item_caption(cap)
        nb.add(tab, text=label, underline=pos)

        self._create_dialog_tab(tab)
        if hasattr(tab, 'blist'): tab_bind[tno] = tab.blist
        tno += 1

        # -- リスト・コンポーネントシート
        if 1:
            tab = Frame(nb).pack(expand=1, fill='both', padx=5, pady=5)
            cap = '&List'
            pos, label = item_caption(cap)
            nb.add(tab, text=label, underline=pos)
            self._create_list_tab(tab)
            tno += 1

        # -- テーブル表示のサンプル
        if 0:
            tab = Frame(nb).pack(expand=1, fill='both', padx=5, pady=5)
            cap = '&Table'
            pos, label = item_caption(cap)
            nb.add(tab, text=label, underline=pos)
            self._create_table_tab(tab)
            tno += 1

        # -- テキスト表示のサンプル
        if 0:
            tab = Frame(nb).pack(expand=1, fill='both', padx=5, pady=5)
            cap = 'Te&xt'
            pos, label = item_caption(cap)
            nb.add(tab, text=label, underline=pos)
            self._create_text_tab(tab)
            tno += 1

        # -- 下部のボタン配置
        if 1:
            fr = Frame(base).pack(expand=0, side='bottom')
            cap = '&Close'
            pos, label = item_caption(cap)
            btn = Button(fr, text=label, underline=pos,
                         command=self.dispose).pack(side='left',
                                                    padx=3,
                                                    pady=3)
            self.cc.bind('<Alt-%s>' % cap[pos + 1].lower(),
                         lambda event, wi=btn: wi.invoke())

        # -- キーバインドの設定
        if 1:
            for ev, cmd in (
                ('<Control-a>', 'select-all'),
                ('<Control-o>', 'open'),
                ('<Control-s>', 'save'),
                ('<Control-q>', 'exit'),
                ('<Control-w>', 'close'),
                ('<F5>', 'datetime'),
            ):
                self.cc.bind(ev, self.bind_proc(cmd))
Пример #8
0
    def _create_dialog_tab(self, tab):
        """ダイアログ・タブシートの作成 """
        blist = []
        tab.blist = blist

        fr = Frame(tab).pack(side='top', fill='x', expand=0, padx=5, pady=5)

        cap = '&Open'
        pos, label = item_caption(cap)
        btn = Button(fr,
                     text=label,
                     underline=pos,
                     command=self.menu_proc('open')).pack(side='left',
                                                          padx=3,
                                                          pady=3)

        self.multi = 1
        cb = Checkbutton(fr, text='multiple', name='multi').pack(side='left',
                                                                 padx=3,
                                                                 pady=3)

        cap = '&Save'
        pos, label = item_caption(cap)
        btn = Button(fr,
                     text=label,
                     underline=pos,
                     command=self.menu_proc('save')).pack(side='left',
                                                          padx=3,
                                                          pady=3)

        # -- ディレクトリ選択

        fr = Frame(tab).pack(side='top', fill='x', expand=0, padx=5, pady=5)
        cap = '&Directory'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)
        ent = Entry(fr, width=25, name='dirinput').pack(side='left',
                                                        padx=3,
                                                        pady=3)
        ent.label = lab
        btn = tk.Button(fr, text='..',
                        command=self.menu_proc('dir')).pack(side='left',
                                                            padx=3,
                                                            pady=3)

        # ポップアップ
        fr = LabelFrame(tab, text='message dialog').pack(side='top',
                                                         fill='x',
                                                         expand=0,
                                                         padx=5,
                                                         pady=5)

        for cap, cmd in (
            ('&Information', 'info-msg'),
            ('&Warning', 'warn-msg'),
            ('&Error', 'error-msg'),
        ):
            pos, label = item_caption(cap)
            btn = Button(fr,
                         text=label,
                         underline=pos,
                         command=self.menu_proc(cmd))
            btn.pack(side='left', padx=3, pady=3)

        fr = LabelFrame(tab, text='confirm dialog').pack(side='top',
                                                         fill='x',
                                                         expand=0,
                                                         padx=5,
                                                         pady=5)
        for cap, cmd in (
            ('&Yes No', 'yes-no'),
            ('&Retry Cancel', 'retry-cancel'),
            ('&Abort Retry Ignore', 'abort-retry-ignore'),
            ('Input &Text', 'input-text'),
        ):
            pos, label = item_caption(cap)
            btn = Button(fr,
                         text=label,
                         underline=pos,
                         command=self.menu_proc(cmd))
            btn.pack(side='left', padx=3, pady=3)

# -- カレンダ選択

        fr = Frame(tab).pack(side='top', fill='x', expand=0, padx=5, pady=5)

        cap = '&Calendar'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)
        ent = Entry(fr, width=15, name='datepickup').pack(side='left',
                                                          padx=3,
                                                          pady=3)
        ent.label = lab
        btn = tk.Button(fr,
                        text='..',
                        command=self.menu_proc('calendar-popup')).pack(
                            side='left', padx=3, pady=3)

        # -- 色選択

        fr = Frame(tab).pack(side='top', fill='x', expand=0, padx=5, pady=5)
        cap = '&Foreground'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

        self.fg_sample = tk.Label(fr, text='   ').pack(side='left', padx=3)

        ent = Entry(fr, width=25, name='foreground').pack(side='left',
                                                          padx=3,
                                                          pady=3)
        ent.bind('<Return>', self.bind_proc('fg_color'))
        ent.label = lab

        btn = tk.Button(fr, text='..',
                        command=self.menu_proc('fg_select')).pack(side='left',
                                                                  padx=3,
                                                                  pady=3)
        cn = 'black'
        self._set_fg_input(cn)
Пример #9
0
    def _create_basic_tab(self, tab):
        """Basicタブを作成 """
        fr = Frame(tab).pack(side='top')

        self.prompt = 'メッセージ表示(変更できます)'
        lab = Label(tab, name='prompt').pack(side='top', fill='x')
        # -- entry
        fr = Frame(tab).pack(side='top')

        cap = 'I&nput'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

        self.input = 'aaa'
        ent = Entry(fr, width=25, name='input').pack(side='left',
                                                     padx=3,
                                                     pady=3)
        ent.bind('<Return>', self.bind_proc('input'))
        ent.label = lab
        entry_focus(ent)

        # -- passwod entry
        fr = Frame(tab).pack(side='top')
        cap = '&Password'
        pos, label = item_caption(cap)
        cap = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

        self.passwd = 'bbb'
        ent = Entry(fr, show='*', width=25, name='passwd').pack(side='left',
                                                                padx=3,
                                                                pady=3)

        # -- button

        fr = Frame(tab).pack(side='top')

        CLOCK = 'ref/meza-bl-2.gif'
        img = find_image(CLOCK)

        cap = 'Change'
        pos, label = item_caption(cap)
        btn = Button(fr,
                     text=label,
                     underline=pos,
                     image=img,
                     compound='top',
                     command=self.menu_proc('input')).pack(side='left',
                                                           padx=3,
                                                           pady=3)
        ui.set_tool_tip(btn, 'メッセージを入力値に置き換えます。')

        # -- combobox(Edit)
        fr = Frame(tab).pack(side='top')

        cap = 'Co&mbobox'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

        ent = Combobox(fr, width=30, name='combo').pack(side='left',
                                                        padx=3,
                                                        pady=3)
        ent['values'] = ('AA', 'BB', 'CC')
        ent.current(1)
        self.combo_ent = ent

        ent.bind('<<ComboboxSelected>>', self.bind_proc('combo'))
        ent.bind('<Return>', self.bind_proc('combo'))
        ent.bind('<Control-j>', self.bind_proc('combo'))

        # -- combobox(Readonly)
        fr = Frame(tab).pack(side='top')
        cap = 'Theme &Select'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

        themes = list(ui.style.theme_names())
        themes.insert(0, 'Pick a theme')
        cmb = Combobox(fr, values=themes, state='readonly', height=8)
        cmb.set(themes[0])
        cmb.pack(side='left', padx=3, pady=3)
        cmb.bind('<<ComboboxSelected>>', self.bind_proc('theme'))
        cmb.label = lab

        # -- Text
        fr = Frame(tab).pack(side='top')
        cap = '&Text'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=3)

        buf = Text(fr, undo=1, maxundo=50, width=25,
                   height=3).pack(side='left', padx=3, pady=3)
        self.buf = buf
        lab.label_for = buf
Пример #10
0
    def create_widgets(self, base):
        cc = self.cc
        fb = Frame(base).pack(side='top',
                              fill='both',
                              expand=1,
                              padx=3,
                              pady=3)

        item_count = 10
        # ----- フォントファミリー

        fr = Frame(fb).pack(side='left', fill='both', expand=1, padx=3, pady=3)

        cap = 'Font &Family'
        cap = 'フォント名(&F)'
        pos, label = item_caption(cap)
        cap = Label(fr, text=label, underline=pos)
        cap.pack(side='top', fill='x', expand=0)

        self.family = var = StringVar()
        var.set('Terminal')
        tf = Entry(fr, width=20, textvariable=var).pack(side='top',
                                                        fill='x',
                                                        expand=0,
                                                        padx=3,
                                                        pady=3)
        ui.register_entry_popup(tf)

        fl = Frame(fr).pack(side='top', fill='both', expand=1)

        self.family_list = lb = Listbox(fl,
                                        height=item_count).pack(side='left',
                                                                fill='both',
                                                                expand=1)
        lb.bind('<Double-1>', self._select_family)

        sb = Scrollbar(fl).pack(side='left', fill='y', expand=0)
        sb.config(command=lb.yview)
        lb.config(yscrollcommand=sb.set)

        for nn in tkfont.families():
            lb.insert(END, nn)

        # ----- サイズ

        fr = Frame(fb).pack(side='left', fill='both', expand=0, padx=3, pady=3)

        cap = '&Size'
        cap = '大きさ(&S)'
        pos, label = item_caption(cap)
        cap = Label(fr, text=label, underline=pos).pack(side='top',
                                                        fill='x',
                                                        expand=0)

        self.size = var = StringVar()
        var.set('9')
        tf = Entry(fr, width=5, textvariable=var).pack(side='top',
                                                       fill='x',
                                                       expand=0,
                                                       padx=3,
                                                       pady=3)
        ui.register_entry_popup(tf)

        fl = Frame(fr).pack(side='top', fill='both', expand=1)

        lb = self.size_list = Listbox(fl, width=5,
                                      height=item_count).pack(side='left',
                                                              fill='both',
                                                              expand=1)
        lb.bind('<Double-1>', self._select_size)

        sb = Scrollbar(fl).pack(side='left', fill='y', expand=0)
        sb.config(command=lb.yview)
        lb.config(yscrollcommand=sb.set)

        for nn in size_list:
            lb.insert(END, nn)

        # ----- スタイル

        fr = Frame(fb).pack(side='left', fill='x', expand=0, padx=3, pady=3)

        self.bold = var = BooleanVar()
        var.set(1)
        cap = '&Bold'
        cap = '太字(&B)'
        pos, label = item_caption(cap)
        cb = Checkbutton(fr,
                         variable=var,
                         text=label,
                         underline=pos,
                         command=self._change_style).pack()

        self.italic = var = BooleanVar()
        var.set(0)
        cap = '&Italic'
        cap = '斜字(&I)'
        pos, label = item_caption(cap)
        cb = Checkbutton(fr,
                         variable=var,
                         text=label,
                         underline=pos,
                         command=self._change_style).pack()

        # ----- サンプルテキスト
        fr = Frame(base).pack(side='top', fill='x', expand=0, padx=3, pady=3)

        self.sample = var = StringVar()
        var.set('''AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]
あいうえお\nアイウエオ亜愛
''')
        cap = Label(fr, textvariable=var).pack()
        var.cap = cap

        cc.bind('<MouseWheel>', self._adjust_size, '+')
        cc.bind('<Button-4>', self._adjust_size, '+')
        cc.bind('<Button-5>', self._adjust_size, '+')

        # ----- ボタン等
        fr = Frame(base).pack(side='bottom',
                              fill='x',
                              expand=0,
                              padx=3,
                              pady=3)

        cap = '&OK'
        cap = '選択(&O)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos,
                     command=self._do_ok).pack(side='left', padx=3, pady=3)

        cap = '&Apply'
        cap = '適用(&A)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos,
                     command=self._do_apply).pack(side='left', padx=3, pady=3)
        #cc.bind('<Alt-a>', lambda event, wi=btn: wi.focus())

        cap = '&Cancel'
        cap = '閉じる(&C)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos,
                     command=self._do_cancel).pack(side='left', padx=3, pady=3)
        cc.bind('<Escape>', lambda ev, wi=btn: wi.invoke())

        for ev, cmd in (('<Control-w>', 'close'), ):
            cc.bind(ev, self.bind_proc(cmd))
Пример #11
0
    def create_widgets(self, base):
        """構成コンポーネントの作成"""
        blist = []
        cc = self.cc
        # ----- 検索キーワード
        fr = Frame(base).pack(side='top', fill='x', expand=1, padx=3, pady=3)
        self.keyFrame = fr

        cap = 'Search &Word'
        cap = '検索テキスト(&W)'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=5)

        tf = self.fkey_ent = Combobox(fr, width=30,
                                      name='fkey').pack(side='left',
                                                        fill='x',
                                                        expand=1,
                                                        padx=3,
                                                        pady=3)
        tf['values'] = searchWords
        tf.focus()
        lab.label_for = tf
        tf.bind('<Return>', self._do_find)
        tf.bind('<Control-j>', self._do_find)

        # ----- 置換キーワード

        fr = Frame(base).pack(side='top', fill='x', expand=1)
        self.replaceFrame = fr

        cap = '&Replace With'
        cap = '置換テキスト(&R)'
        pos, label = item_caption(cap)
        lab = Label(fr, text=label, underline=pos).pack(side='left', padx=5)

        tf = self.rkey_ent = Combobox(fr, width=30,
                                      name='rkey').pack(side='left',
                                                        fill='x',
                                                        expand=1,
                                                        padx=3,
                                                        pady=3)
        tf['values'] = replaceWords
        lab.label_for = tf
        self.rkey = ''

        # ----- 検索方向
        cap = 'Direction'
        cap = '検索方向'
        fr = LabelFrame(base, labelanchor='w', text=cap).pack(side='top',
                                                              padx=2,
                                                              pady=2)

        cap = '&Forward'
        cap = '文末に向かって(&F)'
        pos, label = item_caption(cap)
        Radiobutton(fr, text=label, underline=pos,
                    name='fdir/forward').pack(side='left')

        cap = '&Backward'
        cap = '文頭に向かって(&B)'
        pos, label = item_caption(cap)
        Radiobutton(fr, text=label, underline=pos,
                    name='fdir/backward').pack(side='left')

        self.fdir = 'forward'

        # ----- オプション
        fr = Frame(base).pack(side='top')

        cap = '&Ignore case'
        cap = '文字のケースを無視(&I)'
        pos, label = item_caption(cap)
        Checkbutton(fr, text=label, underline=pos,
                    name='ignoreCase').pack(side='left')
        self.ignoreCase = False

        cap = 'Regular &Expression'
        cap = '正規表現(&E)'
        pos, label = item_caption(cap)
        Checkbutton(fr, text=label, underline=pos,
                    name='regularExp').pack(side='left')
        self.regularExp = False

        # ----- ボタンなど
        fr = Frame(base).pack(side='top', fill='x')

        cap = 'Find &Next'
        cap = '次を検索(&N)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos, command=self._do_find)
        btn.pack(side='left', padx=3, pady=3)
        self.findButton = btn

        cap = 'Replace and Fin&d'
        cap = '置き換えて次を検索(&D)'
        pos, label = item_caption(cap)
        btn = Button(fr, text=label, underline=pos, command=self._do_replace)
        btn.pack(side='left', padx=3, pady=3)
        self.replaceButton = btn

        if self.with_hilight:
            cap = '&Hilight'
            pos, label = item_caption(cap)
            btn = Button(fr,
                         text=label,
                         underline=pos,
                         command=self._do_hilight)
            btn.pack(side='left', padx=3, pady=3)

        cap = '&Close'
        cap = '閉じる(&C)'
        pos, label = item_caption(cap)
        btn = Button(fr,
                     text=label,
                     underline=pos,
                     command=self.menu_proc('close'))
        btn.pack(side='left', padx=3, pady=3)
        cc.bind('<Escape>', lambda ev, wi=btn: wi.invoke())

        for bk, proc in blist:
            cc.bind(bk, proc)
Пример #12
0
    def create_widgets(self, base, ModelClass=_EmptyTableData, *args, **opts):
        """コンポーネントを作成する"""
        cc = self.cc
        td = ModelClass(*args, **opts)
        hinfo = td.column_info

        cols = [hi[0] for hi in hinfo]
        if not cols: raise ui.AppException('no column')

        fr = Frame(base)
        self.style_name = tree_style = 'Sheet%d.Treeview' % 1
        self.table = tbl = Treeview(fr,
                                    takefocus=1,
                                    show='tree headings',
                                    columns=cols,
                                    style=tree_style)
        fr.pack(side='top', expand=1, fill='both')
        ysb = Scrollbar(fr, orient='vertical', command=tbl.yview)
        tbl.configure(yscroll=ysb.set)
        ysb.pack(side='right', fill='y')

        xsb = Scrollbar(base, orient='horizontal', command=tbl.xview)
        tbl.configure(xscroll=xsb.set)
        xsb.bind('<MouseWheel>',
                 lambda e, wi=tbl: wi.xview_scroll(
                     -1 * (1 if e.delta > 0 else -1), 'page'))
        xsb.bind('<Enter>', lambda e, wi=xsb: wi.focus_set())

        if len(hinfo[0]) == 4:
            for col, cap, w, st in hinfo:
                tbl.heading(col,
                            text=cap,
                            command=lambda c=col: sorter(tbl, c, c, 0))
                tbl.column(col, stretch=st, width=w)

        elif len(hinfo[0]) == 6:
            for col, cap, w, st, sc, isFloat in hinfo:
                tbl.heading(col,
                            text=cap,
                            command=lambda tc=col, c=sc, fc=isFloat: sorter(
                                tbl, tc, c, 0, fc))
                tbl.column(col, stretch=st, width=w)

        tbl.column('#0', stretch=False, width=80, anchor='e')
        #tbl.heading('#0', anchor='e')

        tbl.pack(side='left', expand=1, fill='both')
        xsb.pack(side='top', fill='x')
        ui.register_editable_cell(tbl)

        self._load_table_data(td)

        if 0:
            # フォントを指定する場合
            def set_font(font):
                self.font = font

            fn = 'Times-10-normal'
            tbl.after_idle(lambda font=fn: set_font(font))

        shortcut = self.find_menu('tsv-shortcut')
        ui.register_shortcut(tbl, shortcut)

        for ev, cmd in (
            ('<Control-a>', 'select-all'),
            ('<Control-c>', 'copy'),
            ('<Control-d>', 'delete'),
            ('<Control-Insert>', 'copy'),
            ('<Control-v>', 'paste'),
            ('<Shift-Insert>', 'paste'),
            ('<Control-d>', 'duplicate'),
            ('<Control-q>', 'exit'),
            ('<Control-w>', 'close'),
            ('<Delete>', 'delete'),
        ):
            tbl.bind(ev, self.bind_proc(cmd))

        cc.bind('<MouseWheel>', self._adjust_font_size, '+')
        cc.bind('<Button-4>', self._adjust_font_size, '+')
        cc.bind('<Button-5>', self._adjust_font_size, '+')