wx.calendar error

Hello,

I recently use wxpython and my first application use a calendar. This
is the code is generated by wxglade (i use spe too):

self.calendar_ctrl_1 = wx.calendar.CalendarCtrl(self, -1,
style=wx.calendar.CAL_MONDAY_FIRST)

but when I run the app, i have this error:

self.calendar_ctrl_1 = wx.calendar.CalendarCtrl(self, -1,
style=wx.calendar.CAL_MONDAY_FIRST)
AttributeError: 'module' object has no attribute 'calendar'

I'm under Debian Squeeze uptodate and use spe 0.8.4/wxGlade 0.6.3 as i
said, python version 2.6.6 and wxpython 2.6.10.1

Thanks for your help

Razlis

PS.: Sorry for my english, I'm french

[alm>]

Have you got a line like this near the top of the file?

import wx.calendar

Al

···

-----Original Message-----
From: wxpython-users@googlegroups.com [mailto:wxpython-
users@googlegroups.com] On Behalf Of razli
Sent: Monday, December 13, 2010 3:21 AM
To: wxPython-users
Subject: [wxPython-users] wx.calendar error

Hello,

I recently use wxpython and my first application use a calendar. This
is the code is generated by wxglade (i use spe too):

self.calendar_ctrl_1 = wx.calendar.CalendarCtrl(self, -1,
style=wx.calendar.CAL_MONDAY_FIRST)

but when I run the app, i have this error:

self.calendar_ctrl_1 = wx.calendar.CalendarCtrl(self, -1,
style=wx.calendar.CAL_MONDAY_FIRST)
AttributeError: 'module' object has no attribute 'calendar'

I'm under Debian Squeeze uptodate and use spe 0.8.4/wxGlade 0.6.3 as i
said, python version 2.6.6 and wxpython 2.6.10.1

Thanks for your help

Razlis

PS.: Sorry for my english, I'm french

--
To unsubscribe, send email to wxPython-
users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

No, I have this:

import wx

This is the code (I thinks it will better):

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Mon Dec 13 12:13:02 2010

import wx

# begin wxGlade: extracode
# end wxGlade

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.sizer_2_staticbox = wx.StaticBox(self, -1,
"Informations")
        self.frame_1_statusbar = self.CreateStatusBar(3, 0)

        # Tool Bar
        self.frame_1_toolbar = wx.ToolBar(self, -1,
style=wx.TB_HORIZONTAL|wx.TB_3DBUTTONS|wx.TB_TEXT)
        self.SetToolBar(self.frame_1_toolbar)
        self.frame_1_toolbar.AddLabelTool(wx.NewId(), "Ouvrir",
wx.Bitmap("/home/anthony/Dev-app/wxBIR/icons/folder-new.png",
wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "", "")
        self.frame_1_toolbar.AddLabelTool(wx.NewId(), "Preferences",
wx.Bitmap("/home/anthony/Dev-app/wxBIR/icons/applications-
development.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL,
"", "")
        self.frame_1_toolbar.AddLabelTool(wx.NewId(), "A Propos",
wx.Bitmap("/home/anthony/Dev-app/wxBIR/icons/help-browser.png",
wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "", "")
        self.frame_1_toolbar.AddSeparator()
        self.frame_1_toolbar.AddLabelTool(wx.NewId(), "Quitter",
wx.Bitmap("/home/anthony/Dev-app/wxBIR/icons/gnome-logout.png",
wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "", "")
        # Tool Bar end
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("/home/
anthony/Dev-app/wxBIR/icons/no-photos.jpg", wx.BITMAP_TYPE_ANY),
style=wx.FULL_REPAINT_ON_RESIZE)
        self.btn_Precedent = wx.Button(self, -1, u"Précédent")
        self.cb_Rot = wx.ComboBox(self, -1, choices=["Aucune", u"90°
Droite", u"90° Gauche"], style=wx.CB_DROPDOWN)
        self.btn_Suivant = wx.Button(self, -1, "Suivant")
        self.calendar_ctrl_1 = wx.calendar.CalendarCtrl(self, -1,
style=wx.calendar.CAL_MONDAY_FIRST)
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "Qui")
        self.text_ctrl_2 = wx.TextCtrl(self, -1, u"Où")
        self.label_1 = wx.StaticText(self, -1, "Galeries existantes:
")
        self.lstBox_Examples = wx.ListBox(self, -1,
choices=["truc_muvh_dec_2001", "truc_muvh_dec_2001",
"truc_muvh_dec_2001", "truc_muvh_dec_2001", "truc_muvh_dec_2001"],
style=wx.LB_SORT)
        self.bitmap_button_1 = wx.BitmapButton(self, -1, wx.Bitmap("/
home/anthony/Dev-app/wxBIR/icons/dialog-error.png",
wx.BITMAP_TYPE_ANY))

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_TOOL, self.Evt_Btn_Open, id=-1)
        self.Bind(wx.EVT_TOOL, self.Evt_Btn_Prefs, id=-1)
        self.Bind(wx.EVT_TOOL, self.Evt_Btn_About, id=-1)
        self.Bind(wx.EVT_TOOL, self.Evt_Btn_Quit, id=-1)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("Batch Image Resizer")
        self.frame_1_statusbar.SetStatusWidths([-1, 100, 45])
        # statusbar fields
        frame_1_statusbar_fields = ["frame_1_statusbar", "Photos:
1/20", "www"]
        for i in range(len(frame_1_statusbar_fields)):

self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
        self.frame_1_toolbar.SetToolBitmapSize((32, 32))
        self.frame_1_toolbar.SetMargins((5, 5))
        self.frame_1_toolbar.Realize()
        self.bitmap_1.SetMinSize((400, 400))
        self.cb_Rot.SetSelection(0)
        self.lstBox_Examples.SetSelection(0)
        self.bitmap_button_1.SetMinSize((150, 60))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_7 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.StaticBoxSizer(self.sizer_2_staticbox,
wx.VERTICAL)
        sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6 = wx.BoxSizer(wx.VERTICAL)
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6.Add(self.bitmap_1, 0, wx.ALL|
wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 2)
        sizer_3.Add(self.btn_Precedent, 0, 0, 0)
        sizer_3.Add(self.cb_Rot, 0, 0, 0)
        sizer_3.Add(self.btn_Suivant, 0, 0, 0)
        sizer_6.Add(sizer_3, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
        sizer_5.Add(sizer_6, 0, wx.EXPAND, 0)
        sizer_2.Add(self.calendar_ctrl_1, 0,
wx.ALIGN_CENTER_HORIZONTAL, 0)
        sizer_2.Add(self.text_ctrl_1, 0, wx.ALL|wx.EXPAND, 2)
        sizer_2.Add(self.text_ctrl_2, 0, wx.ALL|wx.EXPAND, 2)
        sizer_2.Add((20, 30), 0, wx.EXPAND, 0)
        sizer_4.Add(self.label_1, 0, 0, 0)
        sizer_4.Add(self.lstBox_Examples, 0, wx.EXPAND, 0)
        sizer_2.Add(sizer_4, 1, wx.EXPAND, 0)
        sizer_7.Add(sizer_2, 4, wx.EXPAND, 1)
        sizer_7.Add((20, 27), 0, wx.EXPAND, 0)
        sizer_5.Add(sizer_7, 1, wx.EXPAND, 0)
        sizer_1.Add(sizer_5, 0, wx.EXPAND, 0)
        sizer_1.Add(self.bitmap_button_1, 0, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        self.Centre()
        # end wxGlade

    def Evt_Btn_Open(self, event): # wxGlade: MyFrame.<event_handler>
        print "Event handler `Evt_Btn_Open' not implemented!"
        event.Skip()

    def Evt_Btn_Prefs(self, event): # wxGlade: MyFrame.<event_handler>
        print "Event handler `Evt_Btn_Prefs' not implemented!"
        event.Skip()

    def Evt_Btn_About(self, event): # wxGlade: MyFrame.<event_handler>
        print "Event handler `Evt_Btn_About' not implemented!"
        event.Skip()

    def Evt_Btn_Quit(self, event): # wxGlade: MyFrame.<event_handler>
        print "Event handler `Evt_Btn_Quit' not implemented!"
        event.Skip()

# end of class MyFrame

class MyApp(wx.App):
    def OnInit(self):
        wx.InitAllImageHandlers()
        frame_1 = MyFrame(None, -1, "")
        self.SetTopWindow(frame_1)
        frame_1.Show()
        return 1

# end of class MyApp

if __name__ == "__main__":
    bir = MyApp(0)
    bir.MainLoop()

<snip>

You don't get all wx modules with only "import wx". For example this is from
one of my files and gets wx, pubsub and calendar.

import wx
from wx.lib.pubsub import Publisher as pub
import wx.calendar

I haven't used Glade but maybe there's a place in the GUI for you to specify
additional modules. If so tell it to include "wx.calendar".

Al

···

-----Original Message-----
From: wxpython-users@googlegroups.com [mailto:wxpython-
users@googlegroups.com] On Behalf Of razli
Sent: Monday, December 13, 2010 11:24 AM
To: wxPython-users
Subject: [wxPython-users] Re: wx.calendar error

No, I have this:

import wx

Thanks, it's work now!

Is a bad things to put from wx import *?

···

On Dec 14, 12:32 am, "Al Mansur" <alman...@rusnam.org> wrote:

> -----Original Message-----
> From: wxpython-users@googlegroups.com [mailto:wxpython-
> users@googlegroups.com] On Behalf Of razli
> Sent: Monday, December 13, 2010 11:24 AM
> To: wxPython-users
> Subject: [wxPython-users] Re: wx.calendar error

> No, I have this:

> import wx

<snip>

You don't get all wx modules with only "import wx". For example this is from
one of my files and gets wx, pubsub and calendar.

import wx
from wx.lib.pubsub import Publisher as pub
import wx.calendar

I haven't used Glade but maybe there's a place in the GUI for you to specify
additional modules. If so tell it to include "wx.calendar".

Al

Is a bad things to put from wx import *?
Yes.

Is a bad things to put from wx import *?
Yes.

···

From: Boštjan Mejak

Sent: Tuesday, December 14, 2010 9:09 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wx.calendar error


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

The reason that it is considered bad, (by many but not everybody), to use from XXXX import * is that you are loosing the namespace scoping so if two of your imports have the same name within the namespace then you will not know which one you are getting plus you can not see clearly within your code what is local and what is coming from libraries.

Gadget/Steve

OK! Thanks a lot Steve. I was thinking because the application became too heavy and so became slowly and system surcharge.

But I don’t understand why for the calendar I must specific the import and not for messageDialog, for example.
How can I get this information in the doc of wxpython?

···

On Tue, Dec 14, 2010 at 1:17 PM, Steve Barnes GadgetSteve@live.co.uk wrote:

From: Boštjan Mejak

Sent: Tuesday, December 14, 2010 9:09 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wx.calendar error

Is a bad things to put from wx import *?
Yes.


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

The reason that it is considered bad, (by many but not everybody), to use from XXXX import * is that you are loosing the namespace scoping so if two of your imports have the same name within the namespace then you will not know which one you are getting plus you can not see clearly within your code what is local and what is coming from libraries.

Gadget/Steve

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

OK! Thanks a lot Steve. I was thinking because the application became too heavy and so became slowly and system surcharge.

But I don’t understand why for the calendar I must specific the import and not for messageDialog, for example.
How can I get this information in the doc of wxpython?

···

From: razlis ten

Sent: Friday, December 17, 2010 7:13 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wx.calendar error

On Tue, Dec 14, 2010 at 1:17 PM, Steve Barnes GadgetSteve@live.co.uk wrote:

From: Boštjan Mejak

Sent: Tuesday, December 14, 2010 9:09 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wx.calendar error

Is a bad things to put from wx import *?
Yes.


To unsubscribe, send email to mailto:wxPython-users%2Bunsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

The reason that it is considered bad, (by many but not everybody), to use from XXXX import * is that you are loosing the namespace scoping so if two of your imports have the same name within the namespace then you will not know which one you are getting plus you can not see clearly within your code what is local and what is coming from libraries.

Gadget/Steve


To unsubscribe, send email to mailto:wxPython-users%2Bunsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

That is actually a different question to is it bad to use from wx import *, (which is a subject that has been known to get some hot under the collar to put it mildly), and is not actually a wx issue as much as a python concept.

To really understand what is going on you need to read up a little on the concept of packages in the python documentation. A rough summary is that the developer of a library an organise it into a core and a number of packages, the organisation may be:

a) so that only those parts of the library that are actually used are included in a given program - (size & start-up speed issues),

b) for logical organisation to ease maintenance or use,

c) because different developers have produced different parts of the library (semi-)independently, (often results in similar layout to b).

d) historic reasons i.e. the unix library did it this way so we did to…

e) because of origin, this started off outside of the wx library but was so useful it got included,

f) because it is a python only enhancement of the C++ wx library take a look at the wxPython demo and look out for pyplot and the excellent agw library, most of the Advanced Generic Widgets section.

g) any, all or none of the above.

Just to give a personal example my current work project currently runs to about 260 source files containing 70k lines of code – as you can imagine it was getting hard to find things with everything in a single directory – so I reorganised it into sub-packages and and just putting all the message interface files into a messages package let me move 67 of the files into a messages subdirectory, etc., things are a lot more manageable now.

For the second part of your question - as most of the help document for wxPython is the C++ API it can sometimes be difficult to know when you need to import a package from the wx library but one of the most useful references is the wxPython demo – almost all the controls are there and you can look at the source tab to see what you need to import. If you start off with the same imports as the demo and then remove any that you are not using, (another reason to avoid from AnyLib import * is that you can quickly identify candidates to get rid of from your import list as if you are accessing the members as AnyLib.member then a quick search for AnyLib will establish if it is used or not.

Hope that helps, at least a little.

(All the above is my personal opinion and to the best of my personal knowledge at the moment and should be taken with a large pinch of salt and with apologies to any I have unwittingly insulted)

Gadget/Steve

Of course that help me: It’s clear and give directions.

Thanks Steve, I have some works :wink:

···

On Fri, Dec 17, 2010 at 1:20 PM, Steve Barnes GadgetSteve@live.co.uk wrote:

From: razlis ten

Sent: Friday, December 17, 2010 7:13 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wx.calendar error

OK! Thanks a lot Steve. I was thinking because the application became too heavy and so became slowly and system surcharge.

But I don’t understand why for the calendar I must specific the import and not for messageDialog, for example.
How can I get this information in the doc of wxpython?

On Tue, Dec 14, 2010 at 1:17 PM, Steve Barnes GadgetSteve@live.co.uk > wrote:

From: Boštjan Mejak

Sent: Tuesday, December 14, 2010 9:09 AM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: wx.calendar error

Is a bad things to put from wx import *?
Yes.

To unsubscribe, send email to mailto:wxPython-users%2Bunsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

The reason that it is considered bad, (by many but not everybody), to use from XXXX import * is that you are loosing the namespace scoping so if two of your imports have the same name within the namespace then you will not know which one you are getting plus you can not see clearly within your code what is local and what is coming from libraries.

Gadget/Steve


To unsubscribe, send email to mailto:wxPython-users%2Bunsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

That is actually a different question to is it bad to use from wx import *, (which is a subject that has been known to get some hot under the collar to put it mildly), and is not actually a wx issue as much as a python concept.

To really understand what is going on you need to read up a little on the concept of packages in the python documentation. A rough summary is that the developer of a library an organise it into a core and a number of packages, the organisation may be:

a) so that only those parts of the library that are actually used are included in a given program - (size & start-up speed issues),

b) for logical organisation to ease maintenance or use,

c) because different developers have produced different parts of the library (semi-)independently, (often results in similar layout to b).

d) historic reasons i.e. the unix library did it this way so we did to…

e) because of origin, this started off outside of the wx library but was so useful it got included,

f) because it is a python only enhancement of the C++ wx library take a look at the wxPython demo and look out for pyplot and the excellent agw library, most of the Advanced Generic Widgets section.

g) any, all or none of the above.

Just to give a personal example my current work project currently runs to about 260 source files containing 70k lines of code – as you can imagine it was getting hard to find things with everything in a single directory – so I reorganised it into sub-packages and and just putting all the message interface files into a messages package let me move 67 of the files into a messages subdirectory, etc., things are a lot more manageable now.

For the second part of your question - as most of the help document for wxPython is the C++ API it can sometimes be difficult to know when you need to import a package from the wx library but one of the most useful references is the wxPython demo – almost all the controls are there and you can look at the source tab to see what you need to import. If you start off with the same imports as the demo and then remove any that you are not using, (another reason to avoid from AnyLib import * is that you can quickly identify candidates to get rid of from your import list as if you are accessing the members as AnyLib.member then a quick search for AnyLib will establish if it is used or not.

Hope that helps, at least a little.

(All the above is my personal opinion and to the best of my personal knowledge at the moment and should be taken with a large pinch of salt and with apologies to any I have unwittingly insulted)

Gadget/Steve

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en