mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-21 15:19:48 +00:00
[update] pybfm.py を TkinterDnD2 がなくても起動するよう変更
This commit is contained in:
parent
36c3497492
commit
e92fbfc6ed
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,5 +6,7 @@ build/
|
||||
*.bak
|
||||
*.old
|
||||
|
||||
|
||||
out/
|
||||
|
||||
.mypy_cache
|
||||
tkinterdnd2
|
Binary file not shown.
17
lib/pybfm.py
17
lib/pybfm.py
@ -1,7 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from tkinter import *
|
||||
from tkinterdnd2 import *
|
||||
try:
|
||||
from tkinterdnd2 import *
|
||||
except ImportError:
|
||||
dnd = False
|
||||
else:
|
||||
dnd = True
|
||||
import os
|
||||
import sys
|
||||
import pyboard
|
||||
@ -174,7 +179,10 @@ def do_nothing():
|
||||
##### メイン #####
|
||||
|
||||
# メインウィンドウの生成
|
||||
root = TkinterDnD.Tk()
|
||||
if dnd:
|
||||
root = TkinterDnD.Tk()
|
||||
else:
|
||||
root = Tk()
|
||||
root.title('PyBfm')
|
||||
root.geometry('400x300')
|
||||
pmenu = Menu(root, tearoff=0)
|
||||
@ -191,8 +199,9 @@ pmenu.add_command(label="閉じる", command=do_nothing)
|
||||
frame = Frame(root)
|
||||
# Listboxウィジェットの生成
|
||||
listbox = Listbox(frame, selectmode=EXTENDED)
|
||||
listbox.drop_target_register(DND_FILES)
|
||||
listbox.dnd_bind('<<Drop>>', listbox_drop)
|
||||
if dnd:
|
||||
listbox.drop_target_register(DND_FILES)
|
||||
listbox.dnd_bind('<<Drop>>', listbox_drop)
|
||||
listbox.bind("<KeyPress>", input_key)
|
||||
listbox.bind("<Double-Button-1>", dbl_click)
|
||||
listbox.bind("<Button-3>", pop_menu)
|
||||
|
Loading…
Reference in New Issue
Block a user