GithubHelp home page GithubHelp logo

Comments (9)

jansabai avatar jansabai commented on June 8, 2024 1

And Jason...

IT WORKS !!!
WOW
Super impressed...

from pysimplegui.

jansabai avatar jansabai commented on June 8, 2024 1

Just quickly.
Problem solved for my app.
Guess, seen the code is so simple, it would be good/nice to implement it as an attribute for the column-Widget anyway...

Also, but not important...

def set_hscroll_position(self, percent_from_top):
...that should be "percent_from_left"...

Cheers!

from pysimplegui.

jansabai avatar jansabai commented on June 8, 2024 1

from pysimplegui.

jansabai avatar jansabai commented on June 8, 2024 1

from pysimplegui.

jason990420 avatar jason990420 commented on June 8, 2024

Simple demo code for horizontal-position scroll.

import PySimpleGUI as sg

def set_hscroll_position(self, percent_from_left):
    """
    Attempts to set the horizontal scroll postition for an element's Widget
    :param percent_from_left: From 0 to 1.0, the percentage from the left to move scrollbar to
    :type percent_from_left:  (float)
    """
    if self.Type == sg.ELEM_TYPE_COLUMN and self.Scrollable:
        widget = self.widget.canvas  # scrollable column is a special case
    else:
        widget = self.widget

    try:
        widget.xview_moveto(percent_from_left)
    except Exception as e:
        print('Warning setting the horizontal scroll (xview_moveto failed)')
        print(e)

sg.Element.set_hscroll_position = set_hscroll_position

sg.theme("DarkBlue")
sg.set_options(font=("Courier New", 20))
column_layout = [[sg.Input(f"({row}, {col})", size=6, pad=(0, 0), key=("-IN-", row, col)) for col in range(10)] for row in range(10)]
layout = [
    [sg.Button("<"),
     sg.Column(column_layout, pad=(0, 0), scrollable=True, size_subsample_width=2, size_subsample_height=2, key="-COLUMN-"),
     sg.Button(">")],
]
window = sg.Window("Title", layout, finalize=True)
percent = 0

while True:

    event, values = window.read()

    if event == sg.WIN_CLOSED:
        break
    elif event == "<" and percent > 0:
        percent -= 0.1
        window["-COLUMN-"].set_hscroll_position(percent)
    elif event == ">" and percent < 1.0:
        percent += 0.1
        window["-COLUMN-"].set_hscroll_position(percent)

window.close()

image

from pysimplegui.

jansabai avatar jansabai commented on June 8, 2024

WOW
Such a swift reply!
You are a champ, Jason!

Will try this immediately!!!
Thanks...

And quick question...
I registered as a private user... But my application gets traction, and on top of that, I want to support you guys!!!
HOW DO I CONVERT TO A COMMERCIAL LICENSE?

from pysimplegui.

jansabai avatar jansabai commented on June 8, 2024

Regarding converting the license to COMMERCIAL, maybe just put a button "UPGRADE" on the License Page.
Simple!

Feel free to close this thread.
ISSUE RESOLVED!

Thanks again.

from pysimplegui.

PySimpleGUI avatar PySimpleGUI commented on June 8, 2024

Yesterday I added this feature to 5.0.4.3. Jason and I used the same name set_hscroll_position, except that I used parameter named percent_from_left.

This is the docstring you'll find in the code I checked in.

    def set_hscroll_position(self, percent_from_left):
        """
        Attempts to set the horizontal scroll postition for an element's Widget
        :param percent_from_left: From 0 to 1.0, the percentage from the left to move scrollbar to
        :type percent_from_left:  (float)
        """

This is the test harness I was using to test it:

import PySimpleGUI as sg

col_layout = [[sg.Text('Column')],
            [sg.Multiline(size=(150,40))],
            [sg.Input(key='-IN-')],
            [sg.Text('Text at the bottom')],

            ]

layout = [[sg.Column(col_layout, k='-COL-', scrollable=True, size=(400,400))],
          [sg.VPush()],
          [sg.Text('% to set scroll from left'), sg.In(k='-RIGHT-', s=4), sg.B('Scroll'), sg.Button('Exit'), sg.Sizegrip()]
          ]

window = sg.Window('Scroll Test', layout, resizable=True)

while True:
    event, values = window.read()
    print(event, values)
    if event == sg.WIN_CLOSED or event == 'Exit':
        break
    if event == 'Scroll':
        window['-COL-'].set_hscroll_position(float(values['-RIGHT-'])/100)

window.close()

I forgot to come back to this issue and post that I made the change. I'm sorry about that! I got really busy.

from pysimplegui.

PySimpleGUI avatar PySimpleGUI commented on June 8, 2024

Regarding converting the license to COMMERCIAL, maybe just put a button "UPGRADE" on the License Page.

We are working on this. In the meantime we're writing a FAQ entry on how to go about changing the license.

Thank you for the support!

from pysimplegui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.