我在实现一些GUI到我的simpy模拟中遇到问题。问题在于如何将GUI(最好是在Tkinter中)添加到简单的项目中。赖特现在甚至有创建一个窗口的问题。我认为这是因为当模拟停止运行时,我不能理解Tkinter代码..我知道这是一个非常普遍的问题,但我不知道如何开始。我想要用Tkinter做的是为我的模拟绘制一个拓扑结构,也许能够改变一些参数,并从GUI中运行它。在tkinter中添加GUI到simpy模拟
我已经添加了一部分,当模拟开始时,对象被创建,整个事情超过十倍大,所以我不知道我是否应该在这里添加它。
initialize()
network=Network()
#creating nodes
node=Node(name='node', function='user', interfaceNum=2, possition=[160,990], homeAddress='0000000000000000020000fffe111111')
node.engine.stateTable={'wifiassocresp':'self.changeIp(interface, self.HO)','dissconnect':'node.engine.dissconnect(self.interruptCause, self.interruptCause.passSender)','RngRsp':'self.sendBU()', 'MIPv6BindingAck_LCoA':'self.sendBU(RCoA=True)', 'MihN2nHoCandidateQueryRsp':'self.makeHandover()'}
activate(node, node.start())
ap0=Node(name='ap0', function='ap', interfaceNum=2,possition=[200,1000])
ap0.engine.stateTable={'dissconnect':'self.dissconnect(self.interruptCause, self.interruptCause.passSender)'}
activate(ap0, ap0.start())
..... there is more nodes, but i cut it becouse I thinks that this is not important
activate(ha, ha.start())
ha.engine.HAadresses={'node':{
'interfaceAddress':[node.interfaceList[0], node.interfaceList[0].address],
'homeAddress':[node.homeAddress],}}
simulation=Tasks()
network.drawTopology(nodes=[node, ap1,ap2, map1, ap0, internet, ha])
allNodes=[node, internet, ap1, ap2, map1, ap0, ha]
node.apList=[ap0,ap1,ap2]
ap1.engine.createRouting([node, internet, map1, ap0, ap2, ha])
ap2.engine.createRouting([node, internet, map1, ap0, ap1, ha])
map1.engine.createRouting([node, ap1, internet, ap0,ap2, ha])
ap0.engine.createRouting([node, ap1, ap2, map1, internet, ha])
internet.engine.createRouting([node, ap1, map1, ap0,ap2, ha])
#here starts the simulation
activate(simulation, simulation.run(1))
simulate(until=100000.0)
这里是代码亩GUI
from Tkinter import *
from betaruch import *
class MainWindow:
def __init__(self, master):
ramka=Frame(master)
ramka.pack()
self.przycisk=Button(ramka, text="Wyjscie", fg="red", command=ramka.quit)
self.przycisk.pack(side=LEFT)
self.witam=Button(ramka, text="Uruchom", command=self.uruchomSymulacje)
self.witam.pack(side=LEFT)
def uruchomSymulacje(self):
pass
root=Tk()
onko=MainWindow(root)
root.mainloop()
而且它不suppoused做任何事情,但它甚至desn't显示出来。
好吧,也许这会有所帮助。我注意到当我导入Tkinter和matplotlib时会出现问题。所以也许matplotlib也使用tkinter?
托比你好,请考虑将您实际的代码和你的问题的具体描述(异常消息,截图等)。此信息可能有助于解决此问题。 –
我没有任何错误,问题在于该窗口没有出现。 – tobi