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


Python Plot.str方法代码示例

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


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

示例1: GUI

# 需要导入模块: from plot import Plot [as 别名]
# 或者: from plot.Plot import str [as 别名]

#.........这里部分代码省略.........
        self.start_x_entry.place(x=90, y=163)

        self.start_y_label = tkinter.Label(self, text='Start Y = ', font=('Arial', 11))
        self.start_y_label.place(x=20, y=180)

        self.start_y_entry = tkinter.Entry(self)
        self.start_y_entry.config(width=8)
        self.start_y_entry.insert(0, '0.1')
        self.start_y_entry.place(x=90, y=183)

        self.h_label = tkinter.Label(self, text='h = ', font=('Arial', 11))
        self.h_label.place(x=180, y=160)

        self.steps_label = tkinter.Label(self, text='Steps = ', font=('Arial', 11))
        self.steps_label.place(x=180, y=180)

        self.h_entry = tkinter.Entry(self)
        self.h_entry.config(width=8)
        self.h_entry.insert(0, '0.01')
        self.h_entry.place(x=210, y=163)

        self.steps_entry = tkinter.Entry(self)
        self.steps_entry.config(width=8)
        self.steps_entry.insert(0, '10000')
        self.steps_entry.place(x=240, y=183)

        self.color_label = tkinter.Label(self, text='Color', font=('Arial', 11))
        self.color_label.place(x=20, y=240)

        self.color_box = Combobox(self, values=self.colors)
        self.color_box.set('Black')
        self.color_box.place(x=20, y=265)

        self.add_button = tkinter.Button(self, text='Add', font=('Arial', 13), width=10, command=self.add_graphic)
        self.add_button.place(x=220, y=260)

        self.show_button = tkinter.Button(self, text='SHOW', font=('Arial', 14), width=15, height=2, command=self.show)
        self.show_button.place(x=300, y=350)

        self.plot = Plot()

        self.info_labels = tkinter.Listbox(self, selectmode='MULTIPLE', width=60, height=17)
        self.info_labels.bind('<<ListboxSelect>>', self.on_select)
        self.info_labels.place(x=420, y=20)

    def on_select(self, event):
        selected = event.widget.curselection()
        if not selected:
            return
        num = selected[0]
        self.plot.remove(0)
        self.info_labels.delete(num)

    def show(self):
        self.plot.draw()

    def get_values(self):
        try:
            l_parameter = float(self.l_parameter_entry.get())
        except ValueError:
            self.show_error('l parameter is invalid')
            return
        try:
            m_parameter = float(self.m_parameter_entry.get())
        except ValueError:
            self.show_error('m parameter is invalid')
            return
        start_x = float(self.start_x_entry.get())
        start_y = float(self.start_y_entry.get())
        h = float(self.h_entry.get())
        steps = int(self.steps_entry.get())
        color = self.color_box.get()
        color = re.sub('\s*', '', color)
        return l_parameter, m_parameter, (start_x, start_y), h, steps, color

    def add_graphic(self):
        values = self.get_values()
        if not values:
            return
        l, m, start, h, steps, color = values
        try:
            generator = VanDerPolGenerator(l, m, start, h, steps)
            self.plot.add(generator, color)
            self.info_labels.insert('end', self.plot.str(-1))
        except:
            descr = sys.exc_info()[0]
            self.show_error(descr)

    def show_error(self, description):
        messagebox.showerror('Error', description)

    def get_colors(self):
        file = open('all_colors.txt')
        colors = file.readlines()
        without_spaces = []
        for color in colors:
            new_color = color.replace('\s', '')
            without_spaces.append(new_color)
        file.close()
        return without_spaces
开发者ID:trtz,项目名称:van_der_pol,代码行数:104,代码来源:main.py


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