Create Funcion

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Create Funcion

rausson.gouveia
I want each DEF to represent a Menu. But I can not. Help me
import wx

class Tela(wx.Frame):

def __init__(self, *args, **kwa):
super(Tela, self).__init__(*args, **kwa)
self.Centre()
self.SetTitle("Halzon")
self.SetSize((800,500))
self.FUN()
self.FUN1()


def FUN(self):
menubar = wx.MenuBar()
menu = wx.Menu()

menubar.Append(menu, "NetWork")

menu.Append(wx.NewId(), "Scan")
self.SetMenuBar(menubar)

def FUN1(self):
funBar = wx.MenuBar()
fun = wx.Menu()

funBar.Append(fun, "Web")

fun.Append(wx.NewId(),"DataB")
self.SetMenuBar(funBar)

def main():
app = wx.App()
frame = Tela(None)
frame.Show()
app.MainLoop()
main()

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Create Funcion

Claudia Frank
Normally you only have one MenuBar and multiple Menus.
So something like this

    def __init__(self, *args, **kwa):
       
super(Tela, self).__init__(*args, **kwa)
       
self.Centre()
       
self.SetTitle("Halzon")
       
self.SetSize((800,500))
       
self.menubar = wx.MenuBar()
       
self.FUN()
       
self.FUN1()
       
self.SetMenuBar(self.menubar)

   
def FUN(self):
        menu
= wx.Menu()
       
self.menubar.Append(menu, "NetWork")
        menu
.Append(wx.NewId(), "Scan")

   
def FUN1(self):
        fun
= wx.Menu()
       
self.menubar.Append(fun, "Web")
        fun
.Append(wx.NewId(),"DataB")

Cheers
Claudia

Am Montag, 5. November 2018 16:52:36 UTC+1 schrieb [hidden email]:
I want each DEF to represent a Menu. But I can not. Help me
import wx

class Tela(wx.Frame):

def __init__(self, *args, **kwa):
super(Tela, self).__init__(*args, **kwa)
self.Centre()
self.SetTitle("Halzon")
self.SetSize((800,500))
self.FUN()
self.FUN1()


def FUN(self):
menubar = wx.MenuBar()
menu = wx.Menu()

menubar.Append(menu, "NetWork")

menu.Append(wx.NewId(), "Scan")
self.SetMenuBar(menubar)

def FUN1(self):
funBar = wx.MenuBar()
fun = wx.Menu()

funBar.Append(fun, "Web")

fun.Append(wx.NewId(),"DataB")
self.SetMenuBar(funBar)

def main():
app = wx.App()
frame = Tela(None)
frame.Show()
app.MainLoop()
main()

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Create Funcion

rausson.gouveia
In reply to this post by rausson.gouveia
 Thank you Claudia, I'll do it the way you said, but I have another problem. if I want to open another frame by clicking on the (ex: network) or scan. How should I do it ?? Why do I want to make it open another screen if I click on SubMenus

import wx

class Tela(wx.Frame):

def __init__(self, *args, **kwa):
super(Tela, self).__init__(*args, **kwa)
self.Centre()
self.SetTitle("Halzon")
self.SetSize((800,500))
self.FUN()
self.FUN1()


def FUN(self):
menubar = wx.MenuBar()
menu = wx.Menu()

menubar.Append(menu, "NetWork")

menu.Append(wx.NewId(), "Scan")
self.SetMenuBar(menubar)


def main():
app = wx.App()
frame = Tela(None)
frame.Show()
app.MainLoop()
main()

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Create Funcion

Claudia Frank
You can do it in the same way as you already did with Tela frame class.

Define a new frame

class B(wx.Frame):
   
def __init__(self, *args, **kwa):
       
super(B, self).__init__(*args, **kwa)
       
self.SetTitle("B Frame")
       
self.SetSize((400,200))

bind an menu event to a function like

    def FUN(self):
        menu
= wx.Menu()
       
self.menubar.Append(menu, "NetWork")
        menu
.Append(101, "Scan")
       
self.Bind(wx.EVT_MENU, self._scan, id=101)

create the function which shows the frame

    def _scan(self, event):
        B
(None).Show()

Btw. do you know the wxPython demos? They could be very helpful. See here.

Cheers
Claudia

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Create Funcion

rausson.gouveia
In reply to this post by rausson.gouveia
Claudia I did as you said, but the code still looks like 3 error: I'm sorry, I'll call you for your help every time. I've seen the Phoenix link and it's very good. I'm new to wxPython. I started a few weeks ago.

I'll send the code to you

Thank you very much for your attention !!!!

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

teste.py (889 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Create Funcion

Claudia Frank

No, looks like I wasn't clear enough.
It should be more like this

import wx

class Tela(wx.Frame):

   
def __init__(self, *args, **kwa):
       
super(Tela, self).__init__(*args, **kwa)
       
self.SetTitle("Halzon")
       
self.SetSize((600,300))
       
self.Centre()
       
self.FUN()
       
self.SetBackgroundColour("white")
       
   
def FUN(self):
        menubar
= wx.MenuBar()
        menu0
= wx.Menu()
        menubar
.Append(menu0, "Net")
        menu0
.Append(101, "Scan")
       
self.Bind(wx.EVT_MENU, self._scan, id=wx.ID_ANY)
       
self.SetMenuBar(menubar)

   
def _scan(self, event):
        B
(None).Show()

class B(wx.Frame):
   
def __init__(self, *args, **kwa):
       
super(B, self).__init__(*args, **kwa)
       
self.SetTitle("B Frame")
       
self.SetSize((400, 200))



def main():
    app
= wx.App()
    frame
= Tela(None)
    frame
.Show()
    app
.MainLoop()
main
()

Cheers
Claudia

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.