當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。