What would a guy do?

If I started doing Python again, this time I would probably dive into making some Windows GUI projects. I’ve got about 70 console programs, most of which I could turn into a Windows version.

But would I have to write the same code 70 times in order to create the interface and buttons and textboxes and such?

I’m using WingWare and they said they don’t have templates, because I thought maybe I could save some code as a template and just keep re-using it over and over.

So would I have to download and use a GUI designer like Glade or something to simplify the process?

It’s hard to understand what you’re envisioning here. Would all these programs actually have the same interface, in the first place? What benefit are you hoping to achieve by making GUI versions?

Most use labels, textboxes, some use listboxes. Most use buttons. It’s me getting used to using graphical components and learning how to write code for them. They don’t all look the same necessarily.

My advice is to try making one of these GUIs first, and then see if you still have a question at all, and if it’s (hopefully) a more refined question.

The beautiful thing about using code to generate an interface is that, well, code is code. As programmers we have a huge number of tools available to help us run code 70 times that we don’t have to write 70 times. The exact choice of tool will depend on your needs, but here are a few options:

  1. A loop! It’s a classic. Only useful if you’re doing something like creating a grid layout though.
  2. A list of labels for which you need corresponding inputs. Iterate over your labels, build your rows.
  3. A dictionary mapping some kind of identifier to all the information needed for that thing.
  4. Something more sophisticated, with possibly a recursive constructor system whereby a data structure corresponds to the desired GUI layout
  5. Or a good old classic, a function that wraps up most of the repeated work, which you then call 70 times with different arguments.

Since this is seventy separate programs, there’s also another option too: Put the code into a module and import it. You may still need to pass it some extra information though, which is where the other types of tools come in.

In any case, just think about it like any other code that you’d have to run lots of times. GUI code is, by and large, exactly the same as any other code (with a possible difference being that event-driven code is common in GUIs but less common elsewhere). You should be able to tackle the problem using all your other expereince.

Get in there, have some fun with it, and make a disgusting mess before you make something beautiful. It’s the best way!

1 Like

It sounds like putting the code into a module may be the best way. But what other information I would need to put in I wouldn’t know how to do that part.

Start by making just one of them. Figure out what you need. Then make a second one, while keeping the first in the back of your head. Once you get to the third one, you’ll probably have a good idea of how to generalize it.

1 Like

I have written console programs in both Java and Python. I’ve looked at videos on YouTube for how to incorporate a GUI designer in Java or Python.

It just to me appears kind of clunky with those languages.

Visual Studio and Embarcadero both have built-in GUI designers that look and feel fantastic.

Most of my Windows projects that I’ve made in Visual C# have only used one form, but I have an idea for a 10 question test that may need 10 forms.

And I’m just a hobbyist living in a small, depressed area with no teacher or programming buddy to help me.

If I could learn how to (I can learn how to bring up a basic, blank Window), but to put that code somewhere and be able to re-use it so my next Windows project would be simpler to write that would be good.