I want to set the maximum value of the slider to the value entered in the text box.
(* I want the value in the box on the left to be the maximum value of the slider)
ValueError invalid literal for int () with base 10:''
Corresponding source code
Since the value of self.max is empty from the error statement, I am aware that I get an error saying that the code is invalid for int ().
I'm trying to set the initial value of self.max to 250 with self.start_up (), so I'm at a loss because I don't know what to do.
Supplementary information (FW/tool version, etc.)
import tkinter as tk from tkinter import ttk class Application (tk.Frame): def __init __ (self, master): #Initial setting super () .__ init __ (master) self.pack () self.master.title ("GUI") self.slider () self.start_up () def slider (self): #slider setting self.frame = tk.Frame (self.master) self.frame.pack (side = tk.LEFT) self.Label_max = tk.Label (self.frame, text = "renge") self.Label_max.pack (side = tk.LEFT) self.max = tk.StringVar () self.max_entry = ttk.Entry (self.frame, textvariable = self.max, width = 3) self.max_entry.pack (side = tk.LEFT) M = self.max.get () self.scale = tk.Scale (self.frame, orient ='horizontal', from_ = 0, to = int (M)) self.scale.pack (side = tk.LEFT) def start_up (self): #Maximum slider initial value self.max.set (250) root = tk.Tk () app = Application (master = root) app.mainloop ()
Answer # 1
In the slider function, with no string set in variable
M = self.max.get ()As
An error has occurred because we are trying to convert to an int type while keeping the empty string.
Because the initial value set does not have to be a separate function
Whether to do self.max.set (250) before doing self.max.get () in the slider function as it is
Or if you want to divide by function, call the start_up function before doing self.max.get ().
You can set the event as follows to reflect the numerical value on the slider by inputting the value.
def slider (self): ・ ・ self.max_entry.bind ('<KeyRelease>', self.slider_set) def slider_set (self, event): now = self.max.get () if int (now): self.scale ['to'] = now self.scale.set (now)
Answer # 2
Function within the initialization function
sliderIs probably due to running. Try changing the order.
- put the maximum value of the list of variables in the objective function with python pulp
- c - the maximum value will be a negative number
- [python] i want to get the maximum value within a certain period in a pandas data frame
- python - sumy by specifying the maximum number of characters with sumy
- python - read only the maximum value from multiple csv files and combine them into one file
- i want to get the maximum even number from the python list
- python - i want to divide a binary number into two, store it in a list, and represent it in a different decimal number
- a large number of errors when installing the python library
- python - i want to automatically enter the value of the text box before the transition in the text box after the screen transiti
- where is the minor version number of python that starts by default specified?
- python - valueerror: field'id' expected a number but got'suzukitadashi'
- i want to dynamically change the value of a variable in python and execute it
- python - how to accept number input even if keypressevent is defined for qlineedit in pyside
- python - does the number of arguments match?
- analysis from python stock price data, maximum and minimum
- i want to retrieve a cell value from python
- python - how to output the key and value in the dictionary in any form
- python 3x - how to get the value of scrolledtext
- when graphing a list with matplotlib in python, the number of elements is large and the graph is not displayed
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory