当前位置: 首页>>代码示例>>Python>>正文


Python World.addBot方法代码示例

本文整理汇总了Python中World.addBot方法的典型用法代码示例。如果您正苦于以下问题:Python World.addBot方法的具体用法?Python World.addBot怎么用?Python World.addBot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.addBot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _RGB

# 需要导入模块: import World [as 别名]
# 或者: from World import addBot [as 别名]
class Window:
    @staticmethod
    def _RGB(r, g, b):
        color = '#%02x%02x%02x' % (r, g, b)
        return color

    # Default values
    _menuWidth=200
    _menuHeight=600
    _menuColor = _RGB.__func__(240,240,240)
    _canvasColor = _RGB.__func__(218,218,218)
    _frequency = 20

    # Window constructor
    def __init__(self, w=800, h=600):
        self._root = Tk()
        self._root.title("Braitenberg Vehicles")
        self._root.resizable(width=FALSE, height=FALSE)
        self._canvas = Canvas(self._root,
                              width=w,
                              height=h,
                              bd=1,
                              relief=SUNKEN,
                              background=self._canvasColor,
                              )
        self._menu = Frame(self._root,
                           width=self._menuWidth,
                           height=self._menuHeight,
                           bd=1,
                           relief=SUNKEN,
                           bg=self._menuColor,
                           )
        self._canvas.grid(row=0, column=0, sticky=N+W, padx=2, pady=2)
        self._canvas.grid_propagate(False)
        self._menu.grid(row=0, column=1, sticky=N+W, padx=2, pady=2)
        self._menu.grid_propagate(False)
        self._k11 = StringVar()
        self._k12 = StringVar()
        self._k21 = StringVar()
        self._k22 = StringVar()
        self._bx = StringVar()
        self._by = StringVar()
        self._bs = StringVar()                                          #this is added for the size of the bot
        self._lx = StringVar()
        self._ly = StringVar()
        self._world = World()
        self._initMenu()
        self._isRunning = False

    # Place objects into window
    def _initMenu(self):
        self._menu.columnconfigure(0, weight=1)
        self._menu.columnconfigure(1, weight=1)
        stepButton = Button(self._menu, text="Step", command=self._step)
        quitButton = Button(self._menu, text="Quit", command=exit)
        simButton = Button(self._menu, text="Start Simulation", command=self._sim)
        self._simButton = simButton
        matrixLabel = Label(self._menu, text="K Matrix:")
        k11 = Entry(self._menu, justify=RIGHT, textvariable=self._k11)
        k12 = Entry(self._menu, justify=RIGHT, textvariable=self._k12)
        k21 = Entry(self._menu, justify=RIGHT, textvariable=self._k21)
        k22 = Entry(self._menu, justify=RIGHT, textvariable=self._k22)
        self._k11.set("1")
        self._k12.set("0")
        self._k21.set("0")
        self._k22.set("1")
        botPositionLabel = Label(self._menu, text="Position:")
        botXLabel = Label(self._menu, text="X:")
        botYLabel = Label(self._menu, text="Y:")
        botSizeLabel = Label(self._menu, text="Size:")                  #this is added for the size

        bx = Entry(self._menu, justify=RIGHT, textvariable=self._bx)
        by = Entry(self._menu, justify=RIGHT, textvariable=self._by)
        bs = Entry(self._menu, justify=RIGHT, textvariable=self._bs)    #this is added for the size

        self._bx.set("0")
        self._by.set("0")
        self._bs.set("1")                                               #this is added for the size


        addBotButton = Button(self._menu, text="Add Bot", command=self._addBot)
        lightPositionLabel = Label(self._menu, text="Position:")
        lightXLabel = Label(self._menu, text="X:")
        lightYLabel = Label(self._menu, text="Y:")
        lx = Entry(self._menu, justify=RIGHT, textvariable=self._lx)
        ly = Entry(self._menu, justify=RIGHT, textvariable=self._ly)
        self._lx.set("0")
        self._ly.set("0")
        addLightButton = Button(self._menu, text="Add Light", command=self._addLight)

        # attach objects to menu in position
        stepButton.grid(row=0, column=0, sticky=N)
        quitButton.grid(row=0, column=1, sticky=N)
        simButton.grid(row=1, column=0, columnspan=2, sticky=N)
        matrixLabel.grid(row=2, column=0, columnspan=2, sticky=N)
        k11.grid(row=3, column=0, sticky=N)
        k12.grid(row=3, column=1, sticky=N)
        k21.grid(row=4, column=0, sticky=N)
        k22.grid(row=4, column=1, sticky=N)
        botPositionLabel.grid(row=5, column=0, columnspan=2, sticky=N)
#.........这里部分代码省略.........
开发者ID:dfyvece,项目名称:Braitenberg,代码行数:103,代码来源:Window.py


注:本文中的World.addBot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。