Python Forum
[Tkinter] can i had a cefpython3 to a labelframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] can i had a cefpython3 to a labelframe
#26
(Aug-31-2021, 11:57 AM)deanhystad Wrote: The browser is not a tkinter widget. It cannot be added to a label frame. You need a specialized widget that understands how to host a browser window. That is what the example shows, and it shows it in a fairly concise manner. If there was a two step process for displaying a browser in tkinter don't you think the example would show that?

Have you tried running the example code? That would be my first step. Forget about your program for now and just try running the browser example as is. Does it work like you think? What happens when you resize the window, does the browse resize? Do you like navigation bar? Maybe you'll want that for your program too.

Once you have the example running think about how you can use the example code in your project. The example defines a specialized frame for housing a browser window. Your code can import the example as a module and use that class. Create an instance of "BrowserFrame" and pack it in your label frame. The example code adds the browser to the NavigationBar.
        self.browser_frame = BrowserFrame(self, self.navigation_bar)
        self.browser_frame.grid(row=1, column=0,
                                sticky=(tk.N + tk.S + tk.E + tk.W))
        tk.Grid.rowconfigure(self, 1, weight=1)
        tk.Grid.columnconfigure(self, 0, weight=1)
And the NavigationBar is added to the MainFrame (just a frame that fills the entire root window).
        self.navigation_bar = NavigationBar(self)
        self.navigation_bar.grid(row=0, column=0,
                                 sticky=(tk.N + tk.S + tk.E + tk.W))
If you don't want the Navigation bar I think you could just create an instance of BrowserFrame and add it to a LabelFrame.
label_frame = tk.LabelFrame(root, text='Browser')
label_frame.grid(row=0, column=0, sticky=(tk.N + tk.S + tk.E + tk.W))
tk.Grid.rowconfigure(label_frame , 1, weight=1)
tk.Grid.columnconfigure(label_frame , 0, weight=1)

browser_frame = BrowserFrame(self, label_frame)
browser_frame.grid(row=1, column=0, sticky=(tk.N + tk.S + tk.E + tk.W))
tk.Grid.rowconfigure(browser_frame , 1, weight=1)
tk.Grid.columnconfigure(browser_frame , 0, weight=1)
You probably won't need to make a scrollable frame because the browser will do that for you automatically. I have not run the example, so I don't know for sure

Solid advice here. It's always good to start with working example code before diving into integrating it into your own project. The nuances of hosting a browser window in a Tkinter app are not straightforward, so leaning on a tried-and-true example can save you a lot of headaches.

I totally agree that running the example as-is should be the first step. It'll give you a good sense of what to expect and help you decide if that's the direction you want to go for your project.
Reply


Messages In This Thread
can i had a cefpython3 to a labelframe - by razs - Aug-28-2021, 10:47 AM
RE: can i had a cefpython3 to a labelframe - by munirashraf9821 - Sep-15-2023, 01:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter destroy label inside labelFrame Nick_tkinter 3 4,619 Sep-17-2023, 03:38 PM
Last Post: munirashraf9821
  Issue in Tkinter with winfo_class() and LabelFrame ReDefendeur 1 2,780 Oct-05-2020, 05:52 AM
Last Post: Jeff900

Forum Jump:

User Panel Messages

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