0
こんにちはスタックオーバーフローコミュニティ 私はabaqus用のPythonスクリプトを作成しています。パーツを変更してパスを変更する必要があるときに、パスを使用してabaqusにパーツをインポートする必要があるため、tkinterを使用してGUIを作成して、パーツのパスを設定しなければなりません。 ここに私の問題です:どのようにGUIからソースコードにパス(変数)を読み取るには?abaqusとtkinter用のPythonスクリプト
言い訳私の悪い英語ここ
である私は私のソースコードに変更をしたいここ
import tkinter
class simpleapp_tk(tkinter.Tk):
def __init__(self,parent):
tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
self.entryVariable1 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable1)
self.entry.grid(column=0,row=1,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable1.set(u"Enter text here.")
self.entryVariable2 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable2)
self.entry.grid(column=0,row=2,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable2.set(u"Enter text here.")
self.entryVariable3 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable3)
self.entry.grid(column=0,row=3,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable3.set(u"Enter text here.")
self.entryVariable4 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable4)
self.entry.grid(column=0,row=4,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable4.set(u"Enter text here.")
self.entryVariable5 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable5)
self.entry.grid(column=0,row=5,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable5.set(u"Enter text here.")
self.entryVariable6 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable6)
self.entry.grid(column=0,row=6,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable6.set(u"Enter text here.")
self.entryVariable7 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable7)
self.entry.grid(column=0,row=7,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable7.set(u"Enter text here.")
self.entryVariable8 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable8)
self.entry.grid(column=0,row=8,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable8.set(u"Enter text here.")
self.entryVariable9 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable9)
self.entry.grid(column=0,row=9,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable9.set(u"Enter text here.")
self.entryVariable10 = tkinter.StringVar()
self.entry = tkinter.Entry(self,textvariable=self.entryVariable10)
self.entry.grid(column=0,row=10,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
self.entryVariable10.set(u"Enter text here.")
Label = tkinter.Label(self,text=u" chemin table de paramétrage ")
Label.grid(column=2,row=1)
Label = tkinter.Label(self,text=u" chemin axe ")
Label.grid(column=2,row=2)
Label = tkinter.Label(self,text=u" chemin bague exterieure ")
Label.grid(column=2,row=3)
Label = tkinter.Label(self,text=u" chemin bague interieure ")
Label.grid(column=2,row=4)
Label = tkinter.Label(self,text=u" chemin bague ")
Label.grid(column=2,row=5)
Label = tkinter.Label(self,text=u" chemin calle ")
Label.grid(column=2,row=6)
Label = tkinter.Label(self,text=u" chemin lame M2 ")
Label.grid(column=2,row=7)
Label = tkinter.Label(self,text=u" chemin lame M1 ")
Label.grid(column=2,row=8)
Label = tkinter.Label(self,text=u" chemin Patin1 ")
Label.grid(column=2,row=9)
Label = tkinter.Label(self,text=u" chemin Patin2 ")
Label.grid(column=2,row=10)
button = tkinter.Button(self,text=u" DONE ")
button.grid(column=1,row=11)
self.labelVariable = tkinter.StringVar()
label = tkinter.Label(self,textvariable=self.labelVariable,
anchor="w",fg="white",bg="black")
label.grid(column=0,row=0,columnspan=3,sticky='EW')
self.labelVariable.set(u"hello have a nice day")
self.grid_columnconfigure(0,weight=1)
self.resizable(True,False)
self.update()
self.geometry(self.geometry())
self.entry.focus_set()
self.entry.selection_range(0, tkinter.END)
def OnButtonClick(self):
self.labelVariable.set(self.entryVariable.get()+" (You clicked the button)")
self.entry.focus_set()
self.entry.selection_range(0, tkinter.END)
def OnPressEnter(self,event):
self.labelVariable.set(self.entryVariable.get()+" (You pressed ENTER)")
self.entry.focus_set()
self.entry.selection_range(0, tkinter.END)
if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('GUI for script abaqus')
app.mainloop()
とはGUIのコード
part1Directory='C:/Users/khalil/Desktop/PFE/pieces/axe.stp'
part2Directory='C:/Users/khalil/Desktop/PFE/pieces/bague exterieur.stp'
part3Directory='C:/Users/khalil/Desktop/PFE/pieces/bague interieure.stp'
part4Directory='C:/Users/khalil/Desktop/PFE/pieces/bague.stp'
part5Directory='C:/Users/khalil/Desktop/PFE/pieces/calle.stp'
part6Directory='C:/Users/khalil/Desktop/PFE/pieces/lame inf.stp'
part7Directory='C:/Users/khalil/Desktop/PFE/pieces/lame sup.stp'
part8Directory='C:/Users/khalil/Desktop/PFE/pieces/patin 2.stp'
part9Directory='C:/Users/khalil/Desktop/PFE/pieces/patin.stp'
投稿する[mcve] –
どのバージョンのabaqusをお使いですか? – CodeCupboard