I'm trying to make a floating point slider with tkinter. After I import matplotlib.py the sliders stop working. Does anybody have an idea for why that is? Thank you for your help. PS I'm new to stack so i wasn't sure how to format the code below, sorry for that.
# !/usr/bin/python3
from tkinter import *
#from functools import partial
#import pygame as pg
#import numpy as np
#import sympy as sym
#import mpmath
import matplotlib.pyplot as plt
from math import *
#from pn import *
from gui import *
Panel_bczony_width=205
_width=1200
_height=800
zakres_gora =[50 ,30,200,7,1000,1000,360,100]
zakres_dol =[1 ,1,1 ,3, 1,1 ,330, 1]
class Parametry_ukladu:
def __init__(self, master):
self.master=master
self.pom=Label(self.master, text="Parametry Układu", width=25)
self.pom.pack()
self.scale=[]
self.frame=[]
self.label=[]
self.pom=0
for x in range(8):
self.frame.append(Frame(self.master))
self.label.append(Label( self.frame[x], width=10))
#self.scale.append(Scale( self.frame[x], from_=zakres_dol[x], to=zakres_gora[x], orient=HORIZONTAL, command=lambda x: set_zmienne(self.scale, x)))
self.scale.append(Scale( self.frame[x], from_=1.0, to=100.0, orient=HORIZONTAL, resolution=0.1))
#self.scale[x].set(default_values[x])
self.label[x].pack(side=LEFT)
self.scale[x].pack(side=RIGHT)
self.frame[x].pack(side=TOP)
#wczytaj("domyslne_dane.txt")
root = Tk()
parametry_u = Parametry_ukladu(root)
root.mainloop()
edit. I have found here:Tkinter Matplotlib, backend conflict? that changeing backend of matplotlib should solve the problem. To do that i call sth. like that:
import matplotlib
matplotlib.use('WxAgg')
import matplotlib.pyplot as plt
But then when I try to use for example plt.plot() i get this error:
Traceback (most recent call last):
File "main.py", line 17, in <module>
import matplotlib.pyplot as plt
File "/home/plebania/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2355, in <module>
switch_backend(rcParams["backend"])
File "/home/plebania/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 221, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/plebania/.local/lib/python3.6/site-packages/matplotlib/backends/backend_wxagg.py", line 1, in <module>
import wx
ModuleNotFoundError: No module named 'wx'