質問編集履歴
1
コードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -29,3 +29,121 @@
|
|
29
29
|
アドバイスなどいただけたらと思います。
|
30
30
|
|
31
31
|
よろしくおねがいします。
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```Python
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
import os
|
42
|
+
|
43
|
+
import tkinter as tk
|
44
|
+
|
45
|
+
import tkinter.messagebox as tkm
|
46
|
+
|
47
|
+
import tkinter.filedialog as tkf
|
48
|
+
|
49
|
+
import tempfile
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
def getFiDir(self, event=None):
|
54
|
+
|
55
|
+
h_dir0 = os.path.dirname(__file__)
|
56
|
+
|
57
|
+
h_fileDir = tkf.askopenfilename(filetypes=[("","*.txt")], initialdir=h_dir0 )
|
58
|
+
|
59
|
+
h_mojiichi = h_fileDir.rfind('/')
|
60
|
+
|
61
|
+
h_file_name = h_fileDir[h_mojiichi + 1:]
|
62
|
+
|
63
|
+
h_file_name = h_file_name [0:h_file_name.rfind('.')]
|
64
|
+
|
65
|
+
field1.config(text=str(h_file_name))
|
66
|
+
|
67
|
+
field2.delete(0, tk.END)
|
68
|
+
|
69
|
+
field2.insert(0, h_fileDir)
|
70
|
+
|
71
|
+
h_clip = h_file_name +"\n" + h_fileDir
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
def test():
|
76
|
+
|
77
|
+
# h_clip を使用したい。
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
# __ウインドウ______________
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
if __name__ == '__main__':
|
86
|
+
|
87
|
+
#
|
88
|
+
|
89
|
+
root = tk.Tk()
|
90
|
+
|
91
|
+
root.geometry('600x200+300+180')
|
92
|
+
|
93
|
+
root.title('Convert text to html')
|
94
|
+
|
95
|
+
f1 = tk.Frame(root, bg='#eee', padx=10, pady=10)
|
96
|
+
|
97
|
+
f1.pack(fill='x', side='top')
|
98
|
+
|
99
|
+
f2 = tk.Frame(root, bg='#eee', padx=10, pady=10)
|
100
|
+
|
101
|
+
f2.pack(fill='x', side='top')
|
102
|
+
|
103
|
+
f3 = tk.Frame(root, bg='#eee', padx=10, pady=20)
|
104
|
+
|
105
|
+
f3.pack(fill='x', side='top')
|
106
|
+
|
107
|
+
#
|
108
|
+
|
109
|
+
w1, w2, w3 = 12, 36, 8
|
110
|
+
|
111
|
+
l1 = tk.Label(f1, text=u'ファイル名',anchor='w', width=w1)
|
112
|
+
|
113
|
+
l1.pack(side='left')
|
114
|
+
|
115
|
+
field1 = tk.Label(f1, padx=5, anchor='w', width=w2)
|
116
|
+
|
117
|
+
field1.pack(side='left')
|
118
|
+
|
119
|
+
b1 = tk.Button(f1, text=u'参照', pady=1, width=w3)
|
120
|
+
|
121
|
+
b1.bind('<ButtonRelease-1>', ins_wAction.m_getFiDir)
|
122
|
+
|
123
|
+
b1.pack(side='left')
|
124
|
+
|
125
|
+
l2 = tk.Label(f2, text=u'ディレクトリ:', anchor='w', width=w1)
|
126
|
+
|
127
|
+
l2.pack(side='left')
|
128
|
+
|
129
|
+
field2 = tk.Entry(f2, bg='#efefef', width=w2+8)
|
130
|
+
|
131
|
+
field2.pack(side='left')
|
132
|
+
|
133
|
+
l2_2 = tk.Label(f2, text=u'', width=1)
|
134
|
+
|
135
|
+
l2_2.pack(side='left')
|
136
|
+
|
137
|
+
b_convert = tk.Button(f3, text='convert', padx=20, pady=2, width=w3)
|
138
|
+
|
139
|
+
b_convert.bind('<ButtonRelease-1>', test )
|
140
|
+
|
141
|
+
b_convert.pack()
|
142
|
+
|
143
|
+
#.
|
144
|
+
|
145
|
+
root.mainloop()
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```
|