mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-21 23:29: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
|
*.bak
|
||||||
*.old
|
*.old
|
||||||
|
|
||||||
|
|
||||||
out/
|
out/
|
||||||
|
|
||||||
|
.mypy_cache
|
||||||
|
tkinterdnd2
|
Binary file not shown.
17
lib/pybfm.py
17
lib/pybfm.py
@ -1,7 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from tkinterdnd2 import *
|
try:
|
||||||
|
from tkinterdnd2 import *
|
||||||
|
except ImportError:
|
||||||
|
dnd = False
|
||||||
|
else:
|
||||||
|
dnd = True
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import pyboard
|
import pyboard
|
||||||
@ -174,7 +179,10 @@ def do_nothing():
|
|||||||
##### メイン #####
|
##### メイン #####
|
||||||
|
|
||||||
# メインウィンドウの生成
|
# メインウィンドウの生成
|
||||||
root = TkinterDnD.Tk()
|
if dnd:
|
||||||
|
root = TkinterDnD.Tk()
|
||||||
|
else:
|
||||||
|
root = Tk()
|
||||||
root.title('PyBfm')
|
root.title('PyBfm')
|
||||||
root.geometry('400x300')
|
root.geometry('400x300')
|
||||||
pmenu = Menu(root, tearoff=0)
|
pmenu = Menu(root, tearoff=0)
|
||||||
@ -191,8 +199,9 @@ pmenu.add_command(label="閉じる", command=do_nothing)
|
|||||||
frame = Frame(root)
|
frame = Frame(root)
|
||||||
# Listboxウィジェットの生成
|
# Listboxウィジェットの生成
|
||||||
listbox = Listbox(frame, selectmode=EXTENDED)
|
listbox = Listbox(frame, selectmode=EXTENDED)
|
||||||
listbox.drop_target_register(DND_FILES)
|
if dnd:
|
||||||
listbox.dnd_bind('<<Drop>>', listbox_drop)
|
listbox.drop_target_register(DND_FILES)
|
||||||
|
listbox.dnd_bind('<<Drop>>', listbox_drop)
|
||||||
listbox.bind("<KeyPress>", input_key)
|
listbox.bind("<KeyPress>", input_key)
|
||||||
listbox.bind("<Double-Button-1>", dbl_click)
|
listbox.bind("<Double-Button-1>", dbl_click)
|
||||||
listbox.bind("<Button-3>", pop_menu)
|
listbox.bind("<Button-3>", pop_menu)
|
||||||
|
Loading…
Reference in New Issue
Block a user