目的
tkinterで次のようなGUI用のプログラムを作成したいと考えています.
- GUIのボタンをクリックすると,データベースからそのボタンに対応するテーブル(libre officeのエクセルを使用)を表示する.
- テーブルで選択(左クリック)されたとき,セルを含む行の情報をもとに書類(例えば領収書)を作成する.
質問
次の機能はpython(tkinter)の範囲内で実現可能ですか?また,可能であればどのようなコードになりますか?
エクセルのセルをクリックされたときに別のファイルを開く
どうかよろしくお願いいたします。
その他
UIはおろか,tkinterもあまり詳しくないので,質問が悪ければ申し訳ありません.
お役に立つかは分かりませんが,下に現在のコードを載せております.
質問の答えではなくても,コードのご指摘でも非常にありがたいです.
該当のソースコード
python3
1#coding:UTF-8 2import tkinter as tk 3import numpy as np 4import sql 5import subprocess 6 7def cbCustomerList(evt): 8 cmd = "C:/Users/***/Desktop/Programming/UzushioDataManagementSystem/CustomerList.ods" 9 subprocess.run(cmd, shell = True) 10 pass 11 12def cbBusinessDirectory(evt): 13 print("これは取引先名簿ボタン用の関数です.") 14 pass 15 16def cbReciept(evt): 17 cmd = "C:/Users/***/Desktop/Programming/UzushioDataManagementSystem/NewCarInspectCopy.ods" 18 subprocess.run(cmd, shell = True) 19 pass 20 21bTxtList = ["顧客名簿", "取引先名簿", "領収書"] 22bColorList = ["#ff0000", "#ff4000", "#ff8000"] 23bCmdList = [cbCustomerList, cbBusinessDirectory, cbReciept] 24 25class Application(tk.Frame): 26 def __init__(self, master = None): 27 tk.Frame.__init__(self, master) 28 self.pack() 29 self.createWidgets(bTxtList, eInitList) 30 31 def createWidgets(self, bTxtList, eInitList): 32 b = [] 33 for i, (bTxt, bColor, bCmd) in enumerate(zip(bTxtList, bColorList, bCmdList)): 34 b.append(tk.Button(text = bTxt, bg = bColor, font = 20)) 35 b[i].bind("<Button-1>", bCmd) 36 b[i].pack(padx = 5, pady = 5) 37 38root = tk.Tk() 39root.title("Visualizer for function") 40root.geometry("500x300") 41app = Application(master = root) 42app.mainloop()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。