Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use window inside of tkinter #1360

Open
PanosHatz opened this issue Apr 9, 2024 · 6 comments
Open

Use window inside of tkinter #1360

PanosHatz opened this issue Apr 9, 2024 · 6 comments

Comments

@PanosHatz
Copy link

Can I create a window using create_window and place it inside a frame of my tkinter app somehow?

In general, I am trying to create an app with a tkinter window divided in half where the left half will have a local PDF from my PC and the right half will have some buttons and fields

The reason I want this is because I need to embed a pdf in tkinter window with the ability to select text and copy/paste

@r0x0r
Copy link
Owner

r0x0r commented Apr 10, 2024

No you cannot do that.

I investigated it at some point, but did not find a solution. It might be possible though.

@MominIqbal-1234
Copy link

def delete():
    gui_win = Tk()
    gui_win.withdraw() # remove the main TK window only show message box
    gui_win.iconbitmap('icon.ico')
    msg  = messagebox.askquestion("Message", "Are You Sure Delete Password \t")
    if msg =='yes':
            print("Delete data")
    gui_win.destroy()
    gui_win.mainloop()

@HariZalan
Copy link

Why is this code related, @MominIqbal-1234 ?

@MominIqbal-1234
Copy link

MominIqbal-1234 commented May 2, 2024

Since it's a desktop application, not a web application, integrating Tkinter should be straightforward. :)

import webview
from tkinter import *
from tkinter import messagebox
class Api():
  def delete(self, value):
        gui_win = Tk()
        gui_win.withdraw() # remove the main TK window only show message box
        msg  = messagebox.askquestion("Message", "Are You Sure \t")
        if msg =='yes':
                print("Delete data")
        gui_win.destroy()
        gui_win.mainloop()

webview.create_window("Test", html="<button onclick='pywebview.api.delete(\"Woah dude!\")'>Delete</button>", js_api=Api())
webview.start()

image

@Jzhenli
Copy link

Jzhenli commented May 22, 2024

No you cannot do that.

I investigated it at some point, but did not find a solution. It might be possible though.

pywebview is a lightweight cross-platform wrapper around a webview component that allows to display HTML content in its own native GUI window. Here why use the native gui window to instead of tkinter frame?? As we know, tkinter is a lightweight cross-platform gui too. @r0x0r

@Jzhenli
Copy link

Jzhenli commented May 22, 2024

hi, I find a project tkwebview2 which is based on the pywebview, and display the content on the tkinter frame. @r0x0r @PanosHatz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants