これはビルドしているプログラム全体をわずかに露出していますが、フロントエンドだけです。あなたがアプリを自分で作成したい場合は、先に進んでください。 :PTkinter:グリッドを含むフレームを含むグリッド
タイトルが言うように、私はグリッドを含むフレームを含むグリッドを作ろうとしていますが、いくつかの同様の質問を見て、答えを完全に得られません。私はguisとtkinterには新しく、ソリューションはしばしば特定のプログラムに適しています。だから、私の似たような問題があります。
私がしようとしているのは、ioFrame以外の各フレームが2x2グリッドであるGUI Frame structureのような全体的なフレーム構造で何かを構築することです。 ioFrameには、入力行と出力行の2つの要素があります。要するに、これは論理入力を計算する計算機であり、唯一の "数"は真と偽である。
は、ここに私のコードの気圧です:
from tkinter import *;
class calculator:
#def update(self,
def __init__(self, window):
"""
Constructor method.
"""
self.toCompute = []; self.In = StringVar(); self.Out = StringVar();
# Window title
window.title("Logic Calculator");
# The set of 5 frames.
ioFrame = Frame(window, relief=GROOVE, borderwidth=3); ioFrame.grid(row=0); ioFrame.pack();
nwFrame = Frame(window); nwFrame.grid(row=1,column=0); nwFrame.pack();
neFrame = Frame(window); neFrame.grid(row=1,column=1); neFrame.pack();
swFrame = Frame(window); swFrame.grid(row=2,column=0); swFrame.pack();
seFrame = Frame(window); seFrame.grid(row=2,column=1); seFrame.pack();
# Top 2 rows: the IO portion
Label(ioFrame, textvariable=self.In, relief=SUNKEN).grid(row=0, sticky=W);
Label(ioFrame, textvariable=self.Out).grid(row=1, sticky=E);
# Top left 2x2 Frame: [ (|) ][ T | F ]
brlButton = Button(nwFrame, text='(', height=2, width=10).grid(row=0,column=0);
brrButton = Button(nwFrame, text=')', height=2, width=10).grid(row=0,column=1);
truButton = Button(nwFrame, text='T', height=2, width=10).grid(row=1,column=0);
falButton = Button(nwFrame, text='F', height=2, width=10).grid(row=1,column=1);
# Top right 2x2 Frame: [ AND | OOR ][ NND | NOR ]
andButton = Button(neFrame, text='and', height=2, width=10).grid(row=0,column=0);
oorButton = Button(neFrame, text='oor', height=2, width=10).grid(row=0,column=1);
nndButton = Button(neFrame, text='nnd', height=2, width=10).grid(row=1,column=0);
norButton = Button(neFrame, text='nor', height=2, width=10).grid(row=1,column=1);
# Bottom left 2x2 Frame: [ SSO | IIF ][ NSO | NIF ]
andButton = Button(swFrame, text='sso', height=2, width=10).grid(row=0,column=0);
oorButton = Button(swFrame, text='iif', height=2, width=10).grid(row=0,column=1);
nndButton = Button(swFrame, text='nso', height=2, width=10).grid(row=1,column=0);
norButton = Button(swFrame, text='nif', height=2, width=10).grid(row=1,column=1);
# Bottom right 2x2 Frame:[ EEQ | NEG ][ NEQ | === ]
eeqButton = Button(seFrame, text='eeq', height=2, width=10).grid(row=0,column=0);
negButton = Button(seFrame, text='neg', height=2, width=10).grid(row=0,column=1);
neqButton = Button(seFrame, text='neq', height=2, width=10).grid(row=1,column=0);
comButton = Button(seFrame, text='=', height=2, width=10).grid(row=1,column=1);
if __name__ == "__main__": # Only runs program if this specfic file is opened.
window = Tk(); # The window
calculator(window);
window.mainloop();
私はまだ(私はすでに別のファイルに記述されてきた)これらのコマンドを追加する必要がありますが、私はGUIがために別々に行わ取得しようとしていました今。
私の問題は、私のコードが代わりにこの結果を出力しているということです:Current GUI。これは私がやっていたことから明らかに離れています。そして、これに新しいことは、私はおそらく問題のリストを持っています。
ご協力いただければ幸いです。
どのバージョンを使用していますか?私はpython3を使用していて、提供されたコードは実行されていません。 – Nelson
@ネルソンどのようにわかりますか?万が一、エラーの内容や場所を知っていますか? –
@ネルソンバージョン3.3.2。 –