Change frame contents

I’m developing a database handler

I’m looking to write a parametric search function [complete] - but I’m having trouble integrating it with the GUI.

At the moment I have 2 “screens” - one with a group of drop-down search boxes, and the other with the table. When I click “search” on the drop-down-box-screen, I want it to change over to the other table-screen.

In short, I want to change the contents of a frame to that of another frame - without creating a new window.
-What is the simplest way to do this?

-Do the “old” defintions of buttons need to be de-instantiated?

-What is the best way to store the definitions of each frame?

Many thanks in anticipation!

-Callum

I would do this by creating 2 panels, each a child of the frame. Put them
in box sizer with proportion = 1 and wx.GROW, so that each will fill the
frame if only one is shown. To switch from one to the other, show the new
one, hide the old one, and call Layout() on the sizer or the frame.

···

On Mon, Jul 27, 2015 at 10:28 AM, Callum Robertson < cprobertson1@googlemail.com> wrote:

I'm developing a database handler

I'm looking to write a parametric search function [complete] - but I'm
having trouble integrating it with the GUI.

At the moment I have 2 "screens" - one with a group of drop-down search
boxes, and the other with the table. When I click "search" on the
drop-down-box-screen, I want it to change over to the other table-screen.

In short, I want to change the contents of a frame to that of another
frame - without creating a new window.
-What is the simplest way to do this?
-Do the "old" defintions of buttons need to be de-instantiated?
-What is the best way to store the definitions of each frame?

Many thanks in anticipation!
   -Callum

--
Best Regards,
Michael Moriarity

Hi,

I'm developing a database handler

I'm looking to write a parametric search function [complete] - but I'm having trouble integrating it with the GUI.

At the moment I have 2 "screens" - one with a group of drop-down search boxes, and the other with the table. When I click "search" on the drop-down-box-screen, I want it to change over to the other table-screen.

In short, I want to change the contents of a frame to that of another frame - without creating a new window.

Do you need/want a new window?

-What is the simplest way to do this?

What about using a notebook with two panels. One for the search boxes (criteria) and for the result. When clicking "search" you fill the result panel and switch to it. The user switches back to the criteria panel when they want a new search.

-Do the "old" defintions of buttons need to be de-instantiated?

What buttons?

-What is the best way to store the definitions of each frame?

What are the definitions based on? Are they based on the database schema? You could have a definition per column type in Python/wxPython code and reuse it for each column or use maybe XRC (XRCInformation - wxPyWiki) or ....?

Werner

···

On 7/27/2015 16:28, Callum Robertson wrote:

Hi,
@Werner…:I’ll try out that notepad idea tomorrow!

Sorry, the buttons were the ones saying “search” and “cancel” and whatnot that will be on the search-frame.

Its using SQLite3 as the back end, with a python intermediary and (at the moment) a TKinter GUI. I’m just pulling data by assembling an SQL query based on user input and then returning the data as an array: which is fairly trivial to put into a table. They’re wanting to deploy it onto the shop floor using cheap windows tablet computers though - hence my conversion to WxPython, which just generally looks nicer (and in my limited experience still manages to do more interesting things!)

@Data…: that might be a useful trick for smaller apps! I’ll need to remember it!

In this app though it may be a bit clunky for dealing with a potentially large number of different frames - though I’d hope there wouldn’t be more than five! (different users need different data: for instance some need mostly image-based data like dimensions and cutting charts for CNC tools; while others need more text-based data like a list of spare part)

Thanks very much folks! I’ll let you know how I get on tomorrow once I try them out!

···

On Monday, 27 July 2015 16:07:59 UTC+1, werner wrote:

Hi,

On 7/27/2015 16:28, Callum Robertson wrote:

I’m developing a database handler

I’m looking to write a parametric search function [complete] - but I’m
having trouble integrating it with the GUI.

At the moment I have 2 “screens” - one with a group of drop-down
search boxes, and the other with the table. When I click “search” on
the drop-down-box-screen, I want it to change over to the other
table-screen.

In short, I want to change the contents of a frame to that of another
frame - without creating a new window.

Do you need/want a new window?

-What is the simplest way to do this?

What about using a notebook with two panels. One for the search boxes
(criteria) and for the result. When clicking “search” you fill the
result panel and switch to it. The user switches back to the criteria
panel when they want a new search.

-Do the “old” defintions of buttons need to be de-instantiated?

What buttons?

-What is the best way to store the definitions of each frame?

What are the definitions based on? Are they based on the database
schema? You could have a definition per column type in Python/wxPython
code and reuse it for each column or use maybe XRC
(http://wiki.wxpython.org/XRCInformation) or …?

Werner

Hi,
@Werner...:I'll try out that notepad idea tomorrow!

Sorry, the buttons were the ones saying "search" and "cancel" and
whatnot that will be on the search-frame.

Its using SQLite3 as the back end,

You might want to consider SQLAlchemy so not to look yourself into SQLite3.
  with a python intermediary and (at

the moment) a TKinter GUI. I'm just pulling data by assembling an SQL
query based on user input and then returning the data as an array: which
is fairly trivial to put into a table. They're wanting to deploy it onto
the shop floor using cheap windows tablet computers though - hence my
conversion to WxPython, which just generally looks nicer (and in my
limited experience still manages to do more interesting things!)

What Windows version runs on these tablets? Did you check that Python/wxPython works on them?

Werner

···

On 7/27/2015 18:37, Callum Robertson wrote:

The database supports a few flavours of SQL, just a matter of changing round a few parameters in the config file - we just chose SQLite3 because it had a standard library which was easy to implement (they all are, but the problem is we need to rely on as few 3rd party modules as possible - as downloading anything else means putting a request into the IT dept.

These tablets run windows 8, and when stripped down to the bare-bones operating system (i.e getting rid of all the crapola they were bundled with) they run python/wxpython fairly well - the biggest challenge is making an intuitive GUI, but that goes without saying!

I’m about to start trying the notepad suggestion, will get back to you in a few hours (provided I don’t get called away to do something else! I’m officially an engineer, so if anything breaks I need to leave the safety of my desk and bathe in oil and metal cuttings)!

Thanks again!

···

On Monday, 27 July 2015 21:47:18 UTC+1, werner wrote:

On 7/27/2015 18:37, Callum Robertson wrote:

Hi,

@Werner…:I’ll try out that notepad idea tomorrow!

Sorry, the buttons were the ones saying “search” and “cancel” and

whatnot that will be on the search-frame.

Its using SQLite3 as the back end,

You might want to consider SQLAlchemy so not to look yourself into SQLite3.

with a python intermediary and (at

the moment) a TKinter GUI. I’m just pulling data by assembling an SQL

query based on user input and then returning the data as an array: which

is fairly trivial to put into a table. They’re wanting to deploy it onto

the shop floor using cheap windows tablet computers though - hence my

conversion to WxPython, which just generally looks nicer (and in my

limited experience still manages to do more interesting things!)

What Windows version runs on these tablets? Did you check that
Python/wxPython works on them?

Werner

http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/

Just found that (actually by accident when looking up something else to do with panels) - thought it might help anybody else who stumbles across this problem!

Also tried both of the suggested approaches, and they both work reasonably well - though for some reason I end up confused whenever I try to understand my code using the size-0 sizer method (its a horrible mish-mash of spaghetti code and hacky solutions at the moment!)

Going to try that method with panels just now and see if I can make the code any cleaner, I’ll get back to you once I’ve made some headway! (though I suspect, like yesterday, I’ll spend half the day getting distracted with other tasks!)

···

On Monday, 27 July 2015 15:28:08 UTC+1, Callum Robertson wrote:

I’m developing a database handler

I’m looking to write a parametric search function [complete] - but I’m having trouble integrating it with the GUI.

At the moment I have 2 “screens” - one with a group of drop-down search boxes, and the other with the table. When I click “search” on the drop-down-box-screen, I want it to change over to the other table-screen.

In short, I want to change the contents of a frame to that of another frame - without creating a new window.
-What is the simplest way to do this?

-Do the “old” defintions of buttons need to be de-instantiated?

-What is the best way to store the definitions of each frame?

Many thanks in anticipation!

-Callum

Hi Callum

I like working with the sized_controls, so thought it might help you. See attached code using a notebook, but it could be adjusted/changed to use just panels (I think).

Werner

switchpanel.py (2.62 KB)