Python Forum
Convert tkinter to pyqt
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert tkinter to pyqt
#1
Hi all, is there a converter or something to pass a project in tkinter to pyqt?

I need a browser embed in the main window and only after finishing the project and move to the browser(last thing) i realized that it couldnt be done with tkinter so i have to convert it to pyqt (that i know nothing about)

What do you advice that dont force me to start everything from scratch :(

for example:

from tkinter import *
from tkinter import ttk
from tkinter.scrolledtext import ScrolledText
import tkinter as tk
import requests
from bs4 import BeautifulSoup
import webbrowser

root = Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))


container = ttk.Frame(root)
canvas = tk.Canvas(container)
scrollbar_x = ttk.Scrollbar(container, orient="horizontal", command=canvas.xview)
scrollbar_y = ttk.Scrollbar(container, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas)

scrollable_frame.bind("<Configure>", lambda e: canvas.configure(scrollregion=canvas.bbox("all")))

canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")

canvas.configure(xscrollcommand=scrollbar_x.set)
canvas.configure(yscrollcommand=scrollbar_y.set)

stathomelib = LabelFrame(scrollable_frame, text="Library", padx=5, pady=5, highlightbackground="black",
                         highlightthickness=2)
stathomelib.grid(row=3, column=0, columnspan=2, sticky=NW, pady=2)

stathomedoc = LabelFrame(scrollable_frame, text="Documentation", padx=5, pady=5, highlightbackground="black",
                         highlightthickness=2)
stathomedoc.grid(row=3, column=2, columnspan=2, sticky=NW, pady=2)

stathomeTools = LabelFrame(scrollable_frame, text="External Tools", padx=5, pady=5, highlightbackground="black",
                           highlightthickness=2)
stathomeTools.grid(row=3, column=4, columnspan=2, sticky=NW, pady=2)

# this is were i whant the browser window to show
home_browser = LabelFrame(scrollable_frame, text="", padx=5, pady=5, highlightbackground="black",
                          highlightthickness=2)
home_browser.grid(row=0, column=99, rowspan=99, sticky='ne', pady=2)
valido_browser = tk.IntVar()
valido_browser.set(False)

checkbrowser = tk.Checkbutton(home_browser, fg="blue", selectcolor="red", text="Open in Browser",
                              variable=valido_browser)
checkbrowser.grid(row=0, column=0, columnspan=9, sticky="wn")


def choose_browser(urlbook):
    if valido_browser.get() == 1:
        webbrowser.open(urlbook)
    else:
        home_browser.insert(tk.INSERT, urlbook)

global varLnkOrder
varLnkOrder = ""
varLbook = open("Confs/bookmarks.txt", "r").readlines()

for line in varLbook:
    if ":stathomelib" in line:
        varLnkOrder = stathomelib
        taman = 43
        c = 0
        i = 0

    elif ":stathomedoc" in line:
        varLnkOrder = stathomedoc
        taman = 43
        c = 0
        i = 0

    elif ":stathomeTools" in line:
        varLnkOrder = stathomeTools
        taman = 20
        c = 0
        i = 0

    if len(line) > 1:
        titul, urlbook = line.split('<=>')
        if len(titul) > 1:
            link1 = Label(varLnkOrder, width=taman, text=titul, justify="left", anchor="center", fg="blue",
                      cursor="draft_large")
            link1.grid(row=i, column=c, sticky="n", pady=2)
            link1.bind("<Button-1>", lambda e, urlbook=urlbook: choose_browser(urlbook.rstrip()))
            i += 1
            line == ""



container.pack(expand=1, fill="both")
scrollbar_x.pack(side="bottom", fill="x")
scrollbar_y.pack(side="right", fill="y")
canvas.pack(side="bottom", fill="both", expand=True)





if __name__ == "__main__":
    root.mainloop()
example of the txt

<=>:stathomelib
aaaaswefdee<=>ryweryfgertgjhslkrghkjreshjglkjhlksghklrhsklrhklegrthuyug
aaaaswefdee<=>ryweryfgertgjhslkrghkjreshjglkjhlksghklrhsklrhklegrthuyug/
aaaaswefdee<=>ryweryfgertgjhslkrghkjreshjglkjhlksghklrhsklrhklegrthuyug/

<=>:stathomedoc
aaaaswefdee<=>ryweryfgertgjhslkrghkjreshjglkjhlksghklrhsklrhklegrthuyug
aaaaswefdee<=>ryweryfgertgjhslkrghkjreshjglkjhlksghklrhsklrhklegrthuyug/
aaaaswefdee<=>ryweryfgertgjhslkrghkjreshjglkjhlksghklrhsklrhklegrthuyug/

<=>:stathomeTools
Hex Converter1<=>https://www.rapidtables.com/convert/number/hex-to-decimal.html
Hex Converter2<=>https://www.binaryhexconverter.com/hex-to-decimal-converter
Reply
#2
this code can never work in tkinter.
Reply
#3
(Aug-28-2021, 05:22 PM)Axel_Erfurt Wrote: this code can never work in tkinter.

what code? the one i posted? that code works on tkinter my problem is to convert it to pyqt
Reply
#4
Probably the fact that the code that is shown would not run as it has lost all of its indentations.
Take a look at
https://github.com/cztomczak/cefpython/b...kinter_.py
Reply
#5
Right, and whats in formularios ?
Reply
#6
(Aug-28-2021, 09:21 PM)Yoriz Wrote: Probably the fact that the code that is shown would not run as it has lost all of its indentations.
Take a look at
https://github.com/cztomczak/cefpython/b...kinter_.py

i know, iv tried but its very confusing, i cant seem to point the browser to the labelframe, thats why im asking for help because maybe i need to convert it to pyqt :(
Reply
#7
sorry about that, iv fixed the code
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert combobox user input in to date with tkinter Ame 8 6,759 Jul-01-2020, 09:40 PM
Last Post: Yoriz
  Tkinter or PyQt paul18fr 5 4,374 Aug-18-2019, 09:21 PM
Last Post: FullOfHelp
Question Tkinter VS PyQt siansoft 9 34,051 Sep-27-2016, 09:22 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020