473,382 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Trouble with wxListCtrl

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?'),('p op.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_R ESIZE)
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.current Item)
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()
########
Jul 18 '05 #1
1 4409
pk*******@dea.spamcon.org (chauhan) writes:
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().


Hi, wxPanel or wxFrame has nothing to do with self.currentItem, this
attribute is set to 0 in TestListCtrlPanel.PopulateList in mentioned
example, they register a handler for item selection

EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)

and in this hanler they set it to currently selected item:

def OnItemSelected(self, event):
##print event.GetItem().GetTextColour()
self.currentItem = event.m_itemIndex
# [...]

This method tracks user selection, the other way is to find the
selected item when you need it:

currentItem = self.list.GetNextItem(
-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)

this finds first selected item (first after -1).

--

=*= Lukasz Pankowski =*=
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joost van Rooij | last post by:
Hi, I am having problems deleting one item from a list in a wxListCtrl widget. My thought was to select it as presented below: def onSelect(self, event): self.item = event.GetItem()...
1
by: bmoore | last post by:
Hello. I am working on an application using wxPython that includes a panel with a wxListCtrl populated with data received from a LAN attached database. I want the wxListCtrl panel to be...
1
by: Mark Carter | last post by:
I would like a wxListCtrl with 3 columns in it. The number of rows in it will vary during run-time. In the first column of each row should be a wxCheckBox, which the user can check or uncheck. ...
3
by: Piet | last post by:
Hi there. I am trying to display tabular data in a wxListCtrl. What I get from the script below are only the headers, not the items themselves. The documentation didnt help me much; instead I was...
4
by: Piet | last post by:
Hello. I am working on an XML editor that will not display the xml file as plain text, but will rather work with a combination of a tree view for the main element nodes and some kind of tabular...
0
by: Piet | last post by:
Hello, I am working on a graphical MySQL Frontend written in python/wxPython. The results from a table query are displayed either in a wxGrid or in a wxListCtrl. I would prefer the latter because...
0
by: kalyan.abbaraju | last post by:
Hi, I have to create a ListBox in which I have to move items up and down using DnD. How to create drag and drop call backs in wxListCtrl. I can see EVT_LIST_BEGIN_DRAG but I could not find any...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
2
by: JLupear | last post by:
I am having trouble with my code again, I had prepared a question and the code to upload, however I am having trouble posting it, are there limits to the amount of lines you can post? I split it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.