C
chauhan
Hi,
I am new to pogramming.
I have written a small program which retrieves emails from server,
unless all the messages are loaded only then it displays on screen
properlely. Whole thing works fine if I use events to activate
logMail() after start but I don't know how to activate an event at the
start (witout pressing mouse or menu key) as I want this to load
messages at the start of the program.
I am also having problem with statement
self.list.GetItemText(self.currentItem). The statement
self.currentItem gives the current selected item position on listctrl
this statement works fine in wxPanel (demo example wxlistctrl in
wxPython) and not with
wxFrame which I am using now as I want menubar in my application. Can
some body tell me how to get the current selected items position in
wxListCtrl with wxFrame? Same kind of problem with wxPoint(self.x,
self.y) but I can use wxGetMousePosition().
Also I would like to know how to check if internet connection is on.
Thanks in advance
Chauhan
#########
from wxPython.wx import *
import poplib
from poplib import *
emailloglist=[2,('mail.icenter.net','username?','password?'),('pop.netzero.com','username?',
'password?'),]
list_items = [ "item value", "on any", "Right click", ]
class main_window(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, -1, title, size = (800, 600),
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
splitter = wxSplitterWindow(self, -1, style=wxNO_3D|wxSP_3D)
tID=wxNewId()
self.list = wxListCtrl(splitter, tID,
style=wxLC_REPORT|wxSUNKEN_BORDER|wxLC_SINGLE_SEL)
self.log = wxTextCtrl(splitter, -1, style=wxTE_MULTILINE)
splitter.SplitHorizontally(self.list, self.log, 450)
splitter.SetMinimumPaneSize(20)
self.list.InsertColumn( 0, 'listTitle' )
for x in list_items: self.list.InsertStringItem(0,x)
self.Show(true)
EVT_COMMAND_RIGHT_CLICK(self.list, tID, self.OnRightClick)
EVT_RIGHT_UP(self.list, self.OnRightClick)
self.log.WriteText(emailloglist[emailloglist[0]][2]+'\r\n')
p=self.logMail()
def OnRightClick(self, event):
self.log.WriteText("OnRightClick %s\n" %
self.list.GetItemText(1))#GetItemText(self.currentItem)
if not hasattr(self, "popupID1"):
self.popupID1 = wxNewId()
EVT_MENU(self, self.popupID1, self.OnPopupOne)
menu = wxMenu()
menu.Append(self.popupID1, "FindItem tests")
self.PopupMenu(menu, wxGetMousePosition()) #wxPoint(self.x,
self.y)
menu.Destroy()
def OnPopupOne(self, event): self.log.WriteText("Popup one Find:
"+str(self.list.FindItem(-1, 'on any'))+'\r\n')
def logMail(self):
try:
print wxSocketBase.IsConnected
p = POP3 (emailloglist[emailloglist[0]][0])
self.log.WriteText(p.user
(emailloglist[emailloglist[0]][1])+'\r\n')
self.log.WriteText(p.pass_
(emailloglist[emailloglist[0]][2])+'\r\n')
return p
except error_proto:
self.log.WriteText('msg')
class App(wxApp):
def OnInit(self):
frame = main_window(None, -1, "wxPython: (A Demonstration)")
self.SetTopWindow(frame)
return true
app = App(0)
app.MainLoop()
########
I am new to pogramming.
I have written a small program which retrieves emails from server,
unless all the messages are loaded only then it displays on screen
properlely. Whole thing works fine if I use events to activate
logMail() after start but I don't know how to activate an event at the
start (witout pressing mouse or menu key) as I want this to load
messages at the start of the program.
I am also having problem with statement
self.list.GetItemText(self.currentItem). The statement
self.currentItem gives the current selected item position on listctrl
this statement works fine in wxPanel (demo example wxlistctrl in
wxPython) and not with
wxFrame which I am using now as I want menubar in my application. Can
some body tell me how to get the current selected items position in
wxListCtrl with wxFrame? Same kind of problem with wxPoint(self.x,
self.y) but I can use wxGetMousePosition().
Also I would like to know how to check if internet connection is on.
Thanks in advance
Chauhan
#########
from wxPython.wx import *
import poplib
from poplib import *
emailloglist=[2,('mail.icenter.net','username?','password?'),('pop.netzero.com','username?',
'password?'),]
list_items = [ "item value", "on any", "Right click", ]
class main_window(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, -1, title, size = (800, 600),
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
splitter = wxSplitterWindow(self, -1, style=wxNO_3D|wxSP_3D)
tID=wxNewId()
self.list = wxListCtrl(splitter, tID,
style=wxLC_REPORT|wxSUNKEN_BORDER|wxLC_SINGLE_SEL)
self.log = wxTextCtrl(splitter, -1, style=wxTE_MULTILINE)
splitter.SplitHorizontally(self.list, self.log, 450)
splitter.SetMinimumPaneSize(20)
self.list.InsertColumn( 0, 'listTitle' )
for x in list_items: self.list.InsertStringItem(0,x)
self.Show(true)
EVT_COMMAND_RIGHT_CLICK(self.list, tID, self.OnRightClick)
EVT_RIGHT_UP(self.list, self.OnRightClick)
self.log.WriteText(emailloglist[emailloglist[0]][2]+'\r\n')
p=self.logMail()
def OnRightClick(self, event):
self.log.WriteText("OnRightClick %s\n" %
self.list.GetItemText(1))#GetItemText(self.currentItem)
if not hasattr(self, "popupID1"):
self.popupID1 = wxNewId()
EVT_MENU(self, self.popupID1, self.OnPopupOne)
menu = wxMenu()
menu.Append(self.popupID1, "FindItem tests")
self.PopupMenu(menu, wxGetMousePosition()) #wxPoint(self.x,
self.y)
menu.Destroy()
def OnPopupOne(self, event): self.log.WriteText("Popup one Find:
"+str(self.list.FindItem(-1, 'on any'))+'\r\n')
def logMail(self):
try:
print wxSocketBase.IsConnected
p = POP3 (emailloglist[emailloglist[0]][0])
self.log.WriteText(p.user
(emailloglist[emailloglist[0]][1])+'\r\n')
self.log.WriteText(p.pass_
(emailloglist[emailloglist[0]][2])+'\r\n')
return p
except error_proto:
self.log.WriteText('msg')
class App(wxApp):
def OnInit(self):
frame = main_window(None, -1, "wxPython: (A Demonstration)")
self.SetTopWindow(frame)
return true
app = App(0)
app.MainLoop()
########