473,385 Members | 1,337 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,385 software developers and data experts.

Interesting problem - wxTextCtrl

Hello !

I want to create a tool for mp3 files in wx.

Some sections of the code (see below) is copied from wx demo.

Problems:
1.) the wxStaticText is not centered vertically
2.) the wxTextCtrl is not editable, it is cannot get the focus.
Why ?

My machine OS: winxp.
Python: 2.3,
Wx: for python 2.3

The demo is working, but only my code is not working !
Why ?

Thanx for every help !

FT

PS:
Please send the answers to my private mail address too, because I'm
in digest mode.
#!/usr/bin/python
from wxPython.wx import *
from wxPython.grid import *
from freedb import *
class MainFrame(wxFrame):
def __init__(self, *args, **kwds):
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.AlbumGrid=None
self.Albums=None
self.MainSizer=wxBoxSizer(wxVERTICAL)
self.toppanel = wxPanel(self, -1)
self.bottompanel = wxPanel(self, -1)
self.centpanel = wxPanel(self, -1)
self.toppanel.SetSize((592, 23))
self.bottompanel.SetSize((592, 24))
self.MainSizer.Add(self.toppanel,0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0)
self.MainSizer.Add(self.centpanel,1,wxALL|wxEXPAND ,0)
self.MainSizer.Add(self.bottompanel,1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0)
self.SetAutoLayout(1)
self.SetSizer(self.MainSizer)

self.btnExit = wxButton(self.toppanel, 1220, "Exit")
EVT_BUTTON(self, 1220, self.Exit)
self.btnSearch = wxButton(self.toppanel, 1221, "Search")
EVT_BUTTON(self, 1221, self.OnClickBtn)
self.Text=wxTextCtrl(self, -1, "Search Text", size=(125, -1))
self.Text.SetInsertionPoint(0)
EVT_CHAR(self.Text,self.EvtChar)
self.Label=wxStaticText(self, -1, "Search:")
self.Label.SetBackgroundColour(self.toppanel.GetBa ckgroundColour())
topsizer = wxBoxSizer(wxHORIZONTAL)
topsizer.Add(self.Label, 0,wxLEFT|wxHORIZONTAL|wxVERTICAL|wxALIGN_CENTER_VE RTICAL,2)
topsizer.Add(self.Text, 1,wxLEFT|wxHORIZONTAL,2)
topsizer.Add(self.btnSearch, 1,wxLEFT|wxHORIZONTAL,2)
topsizer.Add(self.btnExit, 1, wxLEFT|wxHORIZONTAL,2)
self.toppanel.SetAutoLayout(1)
self.toppanel.SetSizer(topsizer)
topsizer.SetSizeHints(self.toppanel)

self.centersizer=wxBoxSizer(wxHORIZONTAL)
self.centpanel.SetAutoLayout(1)
self.centpanel.SetSizer(self.centersizer)
self.centersizer.SetSizeHints(self.centpanel)

self.bottomsizer=wxBoxSizer(wxHORIZONTAL)
self.bottompanel.SetAutoLayout(1)
self.bottompanel.SetSizer(self.bottomsizer)
self.bottomsizer.SetSizeHints(self.bottompanel)

self.Layout()
self.Centre()
self.SetTitle("FreeDB Search Dialog")
_icon = wxEmptyIcon()
#_icon.CopyFromBitmap(wxBitmap("EXITEML.ico", wxBITMAP_TYPE_ANY))
#self.SetIcon(_icon)
self.SetSize((640, 480))
self.SetBackgroundColour(wxColour(94, 138, 244))
self.Centre()
# end wxGlade

def EvtChar(self, event):
cc=event.GetKeyCode()
if (cc==13):
self.OnClick(None)
event.Skip()
#self.log.WriteText('EvtChar: %d\n' % event.GetKeyCode())

def OnClickBtn(self,event):
s=self.Text.GetValue()
import freedb
albums=freedb.freedb_search('Last Night Another Soldier',criteria="all")
def sf(a1,a2):
l1=[a1.artist,a1.title,a1.checksum,a1.versions]
l2=[a2.artist,a2.title,a2.checksum,a2.versions]
for i in range(len(l1)):
s1=str(l1[i]).strip();s2=str(l2[i]).strip()
if s1<>s1:
if s1>s2: return 1
else: return -1
return 0
albums.sort(sf)
self.Albums=albums
self.ShowAlbums()

def ShowAlbums(self):
if self.AlbumGrid<>None:
self.AlbumGrid.Destroy()
self.AlbumGrid=None
self.AlbumGrid=grid=wxGrid(self.centpanel,-1)
albs=self.Albums
self.AlbumGrid.CreateGrid(len(albs),4)
EVT_GRID_CELL_LEFT_DCLICK(grid,self.OnSub)
grid.SetColLabelValue(0,"ID")
grid.SetColLabelValue(1,"Artist")
grid.SetColLabelValue(2,"Title")
grid.SetColLabelValue(3,"Versions")
grid.SetColSize(0,80)
grid.SetColSize(1,192)
grid.SetColSize(2,160)
grid.SetColSize(3,80)
for idx in range(len(albs)):
alb=albs[idx]
grid.SetCellValue(idx,0,alb.checksum)
grid.SetCellValue(idx,1,alb.artist)
grid.SetCellValue(idx,2,alb.title)
grid.SetCellValue(idx,3,str(alb.versions))
self.centersizer.Add(self.AlbumGrid,1,wxALL|wxEXPA ND,4)
self.SubGrid=None
self.SubGrid2=None
self.centpanel.Layout()

def OnSub(self,e):
albs=self.Albums
r=e.GetRow()
alb=albs[r]
self.XAlbum=xalb=alb.load()
if self.SubGrid<>None: self.SubGrid.Destroy()
if self.SubGrid2<>None: self.SubGrid2.Destroy()
self.SubGrid=grid=wxGrid(self.bottompanel,-1)
self.SubGrid2=grid2=wxGrid(self.bottompanel,-1)
grid.CreateGrid(len(xalb.tracks),1)
grid2.CreateGrid(6,1)
grid.SetColSize(0,128)
grid.SetColLabelValue(0,"Title")
grid2.SetRowLabelValue(0,"DiscID")
grid2.SetRowLabelValue(1,"Artist")
grid2.SetRowLabelValue(2,"Title")
grid2.SetRowLabelValue(3,"Versions")
grid2.SetRowLabelValue(4,"Genre")
grid2.SetRowLabelValue(5,"Year")
grid2.SetColLabelValue(0,"Value")
grid2.SetColSize(0,128)
#grid.SetColSize(1,192)
for i in range(len(xalb.tracks)):
data=str(xalb.tracks[i][0]).strip()
grid.SetCellValue(i,0,data)
grid2.SetCellValue(2,0,str(xalb.dtitle))
grid2.SetCellValue(0,0,str(xalb.discid))
grid2.SetCellValue(1,0,str(alb.artist))
grid2.SetCellValue(2,0,str(alb.versions))
grid2.SetCellValue(5,0,str(xalb.dyear))
grid2.SetCellValue(4,0,str(xalb.dgenre))
self.bottomsizer.Add(grid2,1,wxALL|wxEXPAND,4)
self.bottomsizer.Add(grid,1,wxALL|wxEXPAND,4)
self.bottompanel.Layout()
e.Skip()

def Exit(self,e):
self.Destroy()
# end of class MyFrame
class FDApplication(wxApp):
def __init__(self,Param,MainFrameClass):
self.MainFrameClass=MainFrameClass
wxApp.__init__(self,Param)
self.MainFrameClass.Application=self
def OnInit(self):
wxInitAllImageHandlers()
MainFrame=self.MainFrameClass(None, -1, "")
#MainFrame=self.MainFrame
#print MainFrame
self.SetTopWindow(MainFrame)
MainFrame.ID=-1
MainFrame.Show(1)
return 1
if __name__ == "__main__":
app=FDApplication(0,MainFrame)
app.MainLoop()


--
Best regards,
fowlertrainer mailto:fo***********@anonym.hu
Jul 18 '05 #1
0 1511

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

Similar topics

3
by: hellprout | last post by:
hi , i have a problem with a wxtextctrl with multiline option. i want to write a file , line after line , in my wxtextctrl . But my file is too longer , and the wxtextctrl can't write the end of...
2
by: Tim | last post by:
How can I set the style attribute in the following wxTextCtrl to a new style AFTER I have already instantiated the wxTextCtrl? I'm trying to toggle the word wrap attribute of the wxTextCtrl, just...
3
by: Russ Phillips | last post by:
I'm just starting to learn Python & wxPython. I have a frame named frSend in a file fSend. On this frame is a wxTextCtrl named txtMsg. I have a module named defs.py I would like to get the value...
2
by: Nicolas Pourcelot | last post by:
Hello, my script worked well until today : when I tried to launch it, I got the following : frame = MyFrame(None,-1,"Geometrie",size=wx.Size(600,400)) File...
0
by: austin | last post by:
I produced 5 wxTextCtrl. My program is to let the user enter the serial number. Each wxTextCtrl has 4 maxlength. My ideal is if the user enter 4 digits on first wxTextCtrl, and the program will...
4
by: Clans Of Intrigue | last post by:
Hello, this is my first post here so apologies if it's in the wrong place, inappropriate or embarrassingly stupid - please let me know :) My problem seems quite simple - I've redirected stdout to...
0
by: alyph | last post by:
Hi, I'm using wxTextCtrl in python (wxPython 2.6, python 2.4). And I used the SetStyle function to change color of some text already shown in the TextCtrl. Everything works fine excpet if I set...
0
by: abcd | last post by:
I have a wxTextCtrl: wx.TextCtrl(self.myPanel, -1, "", style=wx.TE_MULTILINE) I take a set of text (65,000 characters), and paste it into the text control. all looks well. Then when I click...
0
by: ilSignorCarlo | last post by:
Hi, I'd like to display a string in a wxTextCtrl where some selected chars have a different colour from the others. Is there any way a char by specifying is position?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.