2020-01-12 21:28:17

Guys, i wanted to learn WxPython but, it makes me feel really discouraging. i m board at some point. What are your advises do You know any simple dumby tutorial or can someone tell me the basics.

i know it sounds foolish but, sometimes no way you focus on a thing.

2020-01-12 22:33:23

Programming is a constant fight with yourself to read and try to understand, even if your program doesn't make a tea for you. If you're losing that fight it means you won't be a good programmer. My suggestion would be to break it down to a simple modules like "today I will learn what a widget is"
But tomorrow I will learn how to make an application displaying a string after I press a button.
In two days you can say, oh cool I have a button displaying a string. Hm, maybe let's make a calculator.
Wait,. a calculator requires if statements to work, so why not incorporate my knowledge about buttons and if statements to make a simple visual novel based on your buttons?
Then you can say, OK, buttons are boring I can move on to edit boxes. Edit boxes are cool, you can create a simulated login form because why not?
You have a login form? Let's create a notepad replacements! There are millions of these but one more won't damage anyone.
And so on and so forth.

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2020-01-12 23:14:00

@2
Cool advices what was your resources while learning gui programing? and what gui do you use btw?

2020-01-13 04:51:36

Hello,
When I learned the framework, I used this tutorial.
Hope it helps.

Learn from yesterday, live for today, hope for tomorrow.

2020-01-13 07:50:08

Programming is typically goal oriented, a means to an end. If you find yourself getting bored try and think about a potential application to work towards, or narrow your scope to a simple example at a time. Something else to dig into would be the wxPython demo's, which contain examples of many of wxPythons functions. The 4.0.7 version of demos can be found [here].

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-01-13 09:23:15

@3 I do use Winforms, WPF and Xamarin forms, because I use C#./

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2020-01-13 10:53:03

@4
ah i've found that last night and was working on it. highly useful.
@6
do you think C# is way more functional than Python? i think Python is more dependent on 3rd party libraries, do you have the same openeon?

2020-01-13 10:54:29

It depends on what you want to do. I like .NET for how it's written, but you might not like it like I don't like Python for it's forced indentations.

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2020-01-13 10:56:57

But a fact is a fact, .NET has the most extensive STDLib in mainstream languages. However if you started learning Python, make yourself proficient in python before moving to something else.

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2020-01-13 17:19:37

@Nuno
They say C# is way better at automation, is it? na dalso, to extend what i've said previously.

with Python you have to be seaking new libraries even for some very basic thing. Do you feel the same with C#?

2020-01-16 10:19:06

As I said, C# has a very extensive standart library, because that's the .NET framerok. I rarely use 3RD packages, however I know that if I would be developing something very serious then I probably had to plug in one or two. Newtonsoft JSON is essential, while Python has a built-in JSON parser which is good.
Unless you're programming in BGT, you're good to go with everything esle.

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2020-01-23 03:48:17

If you decide to go the Python route, you will want to take a look at this ebook

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station…

2020-01-23 21:11:08

@12
first addition is for p2 outdated already.

2020-01-24 04:15:10 (edited by UltraLeetJ 2020-01-24 04:16:25)

lol, just lol.. the second edition is for p3, if you read and thoroughly examine things, though some fundamentals would never hurt anyone, but turns out I am just wrong then.

now, not sure if installing python 3 by itself will get you wx python does anyone know?
I am interested in making an application to solve a simple problem here and I do not think it would be too complex, but there is lots to learn. Maybe one day that said app will turn it in some form of audio game. I will have to test if wx pythong also gives you a simple accessible gui interface out of the box

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station…

2020-01-24 04:40:46

The differences between Python 2 & 3 core basics are relatively minor, like using brackets with print statements. Its probably preferred to start with Python 3, but hardly world ending if you don't.

@14
Base Python does not come with wxPython, you'll have to install it separately. Many of the GUI interfaces are accessible, but a number of them also aren't, like the AUI notebooks. You can check out the Demo's I mentioned in post 5, though if you want any examples just ask and i'll see what I can do.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-01-24 05:35:39 (edited by Sage_Lancaster 2020-01-24 05:36:14)

At post 15, can you please create examples for tab controls and treeviews? Thank you

2020-01-24 07:22:07

Here's an example of tabs, complete with using the left and right square bracket keys for selecting between them. As for the treeview, well there is a TreeCtrl() set of functions, are you referring more to that?

import wx
 
# Define the tab content as classes:
class TabOne(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        t = wx.StaticText(self, -1, "This is the first tab", (20,20))

class TabTwo(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        t = wx.StaticText(self, -1, "This is the second tab", (20,20))
 
class TabThree(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        t = wx.StaticText(self, -1, "This is the third tab", (20,20))
 
class TabFour(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        t = wx.StaticText(self, -1, "This is the last tab", (20,20))
 
 
class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, title="wxPython tabs example @pythonspot.com")
 
        # Create a panel and notebook (tabs holder)
        self.p = wx.Panel(self)
        self.nb = wx.Notebook(self.p)
 
        # Create the tab windows
        self.tab1 = TabOne(self.nb)
        self.tab2 = TabTwo(self.nb)
        self.tab3 = TabThree(self.nb)
        self.tab4 = TabFour(self.nb)
 
        # Add the windows to tabs and name them.
        self.nb.AddPage(self.tab1, "Tab 1")
        self.nb.AddPage(self.tab2, "Tab 2")
        self.nb.AddPage(self.tab3, "Tab 3")
        self.nb.AddPage(self.tab4, "Tab 4")
 
        # Set noteboook in a sizer to create the layout
        sizer = wx.BoxSizer()
        sizer.Add(self.nb, 1, wx.EXPAND)
        self.p.SetSizer(sizer)

        # bind key presses so they call onkeypress
        self.nb.Bind(wx.EVT_KEY_DOWN,self.onKeyPress)

    def onKeyPress(self, event):
        keycode = event.GetKeyCode()

    #move to left tab
        if keycode == 91:
            if self.nb.GetSelection() == 0:
                self.nb.SetSelection(self.nb.PageCount-1)
            else:
                self.nb.SetSelection(self.nb.GetSelection()-1)

    #move to right tab
        elif keycode == 93:
            if self.nb.GetSelection() == self.nb.PageCount-1:
                self.nb.SetSelection(0)
            else:
                self.nb.SetSelection(self.nb.GetSelection()+1)
 
if __name__ == "__main__":
    app = wx.App()
    MainFrame().Show()
    app.MainLoop()
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-01-24 16:45:15

@magurp244

can You show me a menu bar example that goes to a spesiphic website? think it as a sotfware's company site.

secondly, i need to see some source codes coded by blind programers. i mean the source code with gui? i can find other programer's codes too but, i want to examine what other programers do.

2020-01-24 23:23:39

***up***

2020-01-25 00:42:17

Websites are pretty easy with the webbrowser library:

import wx 
import webbrowser

class Mywin(wx.Frame): 
    def __init__(self, parent, title): 
        super(Mywin, self).__init__(parent, title = title)  

    #setup and bind drop down menu
        menubar = wx.MenuBar() 
    #create sub-menu
        menu = wx.Menu()
    #bind Web to menu
        m_web = menu.Append(wx.ID_SAVE, "W&eb","Your Website Here")
        self.Bind(wx.EVT_MENU, self.web, m_web)
        menubar.Append(menu,"File")
    #set our menubar
        self.SetMenuBar(menubar) 

    #set window size
        self.SetSize((350, 250)) 
        self.Show(True) 

#open new tab/browser to wikipedia
    def web(self,event):
        webbrowser.open('http://www.wikipedia.org')
        
ex = wx.App() 
Mywin(None,'Web demo') 
ex.MainLoop() 
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-01-25 21:13:58

@magurp244

where can i find WxPython demos page?

and also there are afew things that i couldn't understand:

1.is self.web a pre defined wx param or do we put it? if so, where is the parametre that defines self.web in the constructor?

second, how do we make menu IDs? are those random or spesiphic ids existed?

there was one more thing but, forgot it now.

2020-01-25 23:46:24

Check post 5, I put a link to the download for the latest demoes examples.

Self.web is not pre-defined, its just a rando function word I used to define a function thats called when the player triggers the menu item.

There are stock menu ID's set for specific purposes, when you bind a menu item to a function, you also have to apply an ID that gets triggered when it happens, for example:

self.Bind(wx.EVT_MENU, self.web, m_web)

In this segment, were binding the wx.EVT_MENU event ID to call the self.web function when the m_web menu is triggered. So when the menu is triggered, the event thats fired will label itself EVT_MENU, and set off the web function. You can assign unused id's by putting wx.ID_ANY instead, and it will use a number in order when doing that, though i've had a few instances of ID overlap that can occur sometimes, just something to keep in mind when structuring code. There's more on some of the IDs [here], though its not strictly required to use them.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-01-26 23:30:53

magurp244
but, self.web seems to be called from no where? i mean it has no spesiphic ties.

and also, to open wikipedia in the new tab, what exactly triggers opening of the site? is it *event* paramtre of web function?

and there is this "Your website name here" string out there. you , it seems disabled isn'T it? i mean you already put wikipedia out there so what is that demo/example string for?

i know i've asked a lot but, i gui was the tuffest part i've encountered while learning Python.

2020-01-27 00:17:57 (edited by magurp244 2020-01-27 00:19:29)

wxPython uses an internal [event handler], which deals with events from the windowing system. When you Bind something, it adds that to the event handler, which tells it to look out for event X, and do Y when it happens. So in this case, when we use a line like:

self.Bind(wx.EVT_MENU, self.web, m_web)

Were telling the event handler to look out for a menu event coming from the m_web menu item, if it triggers, call self.web. You don't necessarily see this directly in the code because the event handler is whats dealing with it behind the scenes. The triggering of opening the website has nothing to do with wxPython, that is handled by the [webbrowser] library. So, to recap whats happening here, we Bind the m_web menu item to the event handler in wxPython so it will monitor and call self.web if someone triggers it. When triggered, self.web calls webbrowser to open the url in whatever browser there happens to be.

The text string "Your website name here" is purely arbitrary, thats actually a description of the menu item when someone mouses over it that would appear in the statusbar, if it had one. For creating menu's you have a Menu Bar, and Menus. Each Menu represents a single drop down menu, like File, Edit, View, etc. To add options to a drop down menu you Append them, like so:

m_web = menu.Append(wx.ID_SAVE, "W&eb","Your Website Here")

The syntax here is ID, name on the menu, and description, which shows up on the status bar when the menu item is selected. You can add all kinds of items to it if your like, but then you add it to the menubar and giv it a name, in this case "file":

menubar.Append(menu,"File")

So, you create drop down menu's and attach items to them, which are set to watch for events and trigger functions when they happen, then add each menu to the menu bar, and then set the menubar to the current window.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-01-27 19:18:47 (edited by Turkce_Rap 2020-01-27 19:21:27)

magurp
thank your for your answers and btw. why super function refers to mywin instead of a supperior class?