Open dharper08 opened 4 years ago
To control the tick marks with the current implementation, you use the tick_interval parameter.
These 2 sliders
Were created with this code.
import PySimpleGUIQt as sg
layout = [
[sg.Text('My layout') ],
[sg.Slider((0,100), tick_interval=10, key='-SLIDER-'),
sg.Slider((0,100), tick_interval=1000, key='-SLIDER2-')],
[sg.Button('OK')]
]
window = sg.Window('My window', layout)
while True:
event, values = window.read()
print(event, values)
if event is None:
break
I'll look into how to best indicate no tick intervals at all are to be displayed. For the time being, you can set it to a high value and you'll see only 1 tick at the very top.
I'll change this Issue to be an enhancement request to control the ticks.
I've done a bit more digging and found that, while the code for setting tick position is implemented, the class definition does not yet support setting a value. Currently, the value is hard coded with the statement "position = QSlider.TicksBothSides" on line 5539 of PySimpleGUIQt.py. If I simply change this to "position = QSlider.NoTicks" I get the default behavior I need. I'm guessing that since this is still a work in progress that eventually this feature will be implemented. In the meantime I'm off and running. I am also extremely impressed with what I've seen so far. After more than 25 years of working with only the Tk environment it's wonderful to have some new options.
You can always directly manipulate any of the underlying Qt (or any of the other ports) Widgets by accessing the member variable Widget
.
window[slider_key].Widget
will access the Qt slider QSlider
Widget that's being used.
Wow - just as I hit the submit button the screen updated with your comment. I had previously set the tick interval to a very large number and verified that it removed all but the initial tick. I just now saw your update and will look into directly manipulating the Qt Widget if only to get familiar with that capability. Please consider the enhancement request a low priority - I have a workaround and I'm sure you have higher priority issues to work on.
Oh, wait, there's already a parameter to control all of this.... the relief parameter
.
Use these values:
RELIEF_TICK_POSITION_NO_TICKS
RELIEF_TICK_POSITION_BOTH_SIDES
RELIEF_TICK_POSITION_ABOVE
RELIEF_TICK_POSITION_BELOW
RELIEF_TICK_POSITION_LEFT
RELIEF_TICK_POSITION_RIGHT
import PySimpleGUIQt as sg
layout = [
[sg.Text('My layout') ],
[sg.Slider((0,100), relief=sg.RELIEF_TICK_POSITION_NO_TICKS, key='-SLIDER2-')],
[sg.Button('OK')]
]
window = sg.Window('My window', layout)
while True:
event, values = window.read()
print(event, values)
if event is None:
break
It needs to be better documented.
Just verified that your solution above works. Thank you.
For Qt questions, take a look at the Qt readme located in the PySimpleGUIQt folder https://github.com/PySimpleGUI/PySimpleGUI/tree/master/PySimpleGUIQt. It has clues that can answer questions, even if not directly documented. Searching for slider in the readme I see in the release notes this:
Slider tick positions set using relief parm
Type of Issues (Enhancement, Error, Bug, Question)
Enhancement / Question
Operating System
Linux (Mint 19.3)
Python version
3.6
PySimpleGUI Port and Version
PySimpleGUIQt Version 0.31.0 (12/24/2019)
Your Experience Levels In Months or Years
1 Yr Python programming experience 48 Yrs Programming experience overall Yes_____ Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)?
You have completed these steps:
Code or partial code causing the problem
Qt_Widget_Summary.py in ./PySimpleGUIQt/Demo Programs
I am evaluating PySimpleGUIQt to update a GUI created in Tkinter using the PAGE GUI designer. One of the elements needed in the GUI is the Slider (Scale under Tkinter). To evaluate the various elements available I have run the Qt_Widget_Summary.py program but was confused by the parallel lines on either side of the vertical slider. After doing some investigating, it turns out that these are tickmarks spaced so closely that they resemble a line (default setting is None). Looking through PySimpleGUIQt.py I see that the call to QT_Slider.setTickInterval() is implemented and determines the tickmark spacing. However, there currently seems to be no way to disable tickmarks completely. They can be set extremely far apart but there is always an initial tickmark at the start of the slider. Checking QT documentation, it looks like they have a tickPosition capability that determines where (or if) tickmarks are used. Will this eventually be implemented in PySimpleGUIQt?