Giter VIP home page Giter VIP logo

Comments (8)

Whitelegs avatar Whitelegs commented on May 28, 2024 3

Yes, that's exactly it! and select_clear does indeed do the job. Thank you so much for continuing to explore the issue & coming up with a solution. After 30+ years of software development using high level database languages I'm now playing with Python/PySimpleGUI in my retirement & seeing what I can/can't do with it.
I'd also like to take the opportunity to thank you for such a wonderful tool; I've toyed with a couple of other Python GUI products but love the logic of yours & the support you provide is brilliant, far more than I expected. Much appreciated. LOVE YOUR WORK!

from pysimplegui.

Whitelegs avatar Whitelegs commented on May 28, 2024 1

That's great, thanks

from pysimplegui.

jason990420 avatar jason990420 commented on May 28, 2024

I cannot run your code to see what happened.

For following code, it didn't show any problem described in your question.

import PySimpleGUI as sg

size = 21
sg.set_options(font=("Courier New", 11))

layout = [
    [sg.Text("Slideshow Title", size=size),
     sg.Input(expand_x=True, key="-TITLE-")],
    [sg.Text("Wallpaper Config File", size=size),
     sg.Input(expand_x=True, key="-WALLPAPER-")],
    [sg.Text()],
    [sg.Text("Get photos from", size=size),
     sg.Input("/home/dje/Backgrounds", key="-PHOTOS-"),
     sg.FolderBrowse(key='-LU_PHOTOS-')],
    [sg.Text("Collection Name", size=size),
     sg.Input("/home/dje/Pictures/slidershow/albany.xml", key="-COLLECTION-"),
     sg.FolderBrowse(key='-LU_COLLECTION-')],
    [sg.Text()],
    [sg.Text("Display for", size=size),
     sg.Spin([10, 20, 30, 40, 50], initial_value=30, size=5, key="-DTIME-")],
    [sg.Text("Transition Lasts", size=size),
     sg.Spin([(i+1)/10 for i in range(10)], initial_value=0.5, size=5, key="-TTIME-")],
    [sg.Push(),
     sg.Button("OK"),
     sg.Button("Cancel")],
]

window = sg.Window("Gnome Background Slideshow", layout, return_keyboard_events=True, use_default_focus=False, finalize=True)
window['-PHOTOS-'].bind('<FocusOut>', '+EXIT+')

while True:

    event, values = window.read()

    if event == sg.WIN_CLOSED:
        break

    if event != sg.TIMEOUT_EVENT:
        print(event, values)
    """
    if event == '-PHOTOS-+EXIT+':
        window['-LU_PHOTOS-'].set_focus(force=True)
    """
window.close()

image

from pysimplegui.

Whitelegs avatar Whitelegs commented on May 28, 2024

Hmm, that's interesting. I've copied your code, run it & still have the same issue (I tried to get a screenshot of my result but from it you can't tell that the focus has moved to the button, just that the previous field is still highlighted). Just to confirm, you're tabbing through the fields & getting that result? If so, maybe it's something to do with my OS (Linux Pop!-OS 22.04, Gnome 42.9) & there's nothing I can do about it. I might grab my wife's Windows machine & see what that does.

from pysimplegui.

PySimpleGUI avatar PySimpleGUI commented on May 28, 2024

Focus highlighting is different on Linux than on Windows. There may be a difference as well depending on which desktop manager being used on Linux. It's odd that the previous one remains highlighted.

from pysimplegui.

PySimpleGUI avatar PySimpleGUI commented on May 28, 2024

even though it gets the focus the last input field retains the highlight.

By highlight, do you mean "selected"? That is to say, the text is inverse. Like this:

image

Here's a Trinket for you to try.

https://trinket.io/pygame/94e9026195

Please let me know if it has the behavior you are describing. I do see a difference between Linux and Windows. Trinket is Linux based.

You can clear the selection on an input element by using this kind of call:

window['-PHOTOS-'].widget.select_clear()

This may be a way to get what you're after.

from pysimplegui.

PySimpleGUI avatar PySimpleGUI commented on May 28, 2024

image

Thrilled to hear on all fronts. Thank you so very much for the complements and incredible display of gratitude. Your message shows extremely well why I'm excited to work every single day. Making a difference in other programmer's lives is so very rewarding. You've made my day, week, and likely month.

I too come from a deep-time era of programming... C and the PC were years away when I worked on my first product. Python was a new discovery for me a few months before beginning writing PySimpleGUI. It quickly felt like "home" to me... that I had found the language I had dreamed of in so many ways.

PySimpleGUI's logic, design, documentation were from living in that era. PySimpleGUI was never meant to be a "thing". It was a throw-away piece of code meant for my own consumption as a way to write another program. I had fun using it and realized that maybe others would have fun with it too.

Thank you again, you truly made quite an impact. image

from pysimplegui.

PySimpleGUI avatar PySimpleGUI commented on May 28, 2024

I added and checked in a change in version 5.0.4.8 that enables you to use the Input.update call to change the selection. Previously, you could only set the value to True which would select the contents. Now you can also set it to False which will unselect it.

Here's a test harness:

import PySimpleGUI as sg


layout = [  [sg.Text('Test of Input.update select')],
            [sg.Input(12345, key='-IN-', metadata=True)],
            [sg.Text('Not Selected', key='-OUT-')],
            [sg.Button('Go'), sg.Button('Exit')]  ]

window = sg.Window('Window Title', layout)

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Exit':
        break
    if event == 'Go':
        if window['-IN-'].metadata:
            window['-IN-'].update(select=True)
            window['-OUT-'].update('Selected')
        else:
            window['-IN-'].update(select=False)
            window['-OUT-'].update('Not Selected')
        window['-IN-'].metadata = not window['-IN-'].metadata

window.close()

Input update select=False

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.