As a fun little task to gain more knowledge of python, i decided to try to mimick the ipod UI with it. here's what i've got so far - #!/usr/bin/env python
-
# -*- coding: utf-8 -*-
-
# generated by wxGlade 0.5 on Sat Oct 27 15:46:36 2007
-
-
import wx, os, pygame
-
pygame.init()
-
-
class MyFrame2(wx.MDIChildFrame):
-
def __init__(self, *args, **kwds):
-
# begin wxGlade: MyFrame2.__init__
-
kwds["style"] = wx.DEFAULT_FRAME_STYLE
-
wx.MDIChildFrame.__init__(self, *args, **kwds)
-
self.__set_properties()
-
self.__do_layout()
-
# end wxGlade
-
-
def __set_properties(self):
-
# begin wxGlade: MyFrame2.__set_properties
-
self.SetTitle("frame_3")
-
# end wxGlade
-
-
def __do_layout(self):
-
# begin wxGlade: MyFrame2.__do_layout
-
sizer_2 = wx.BoxSizer(wx.VERTICAL)
-
sizer_2.Add(self.tree_2, 1, wx.EXPAND, 0)
-
self.SetSizer(sizer_2)
-
sizer_2.Fit(self)
-
self.Layout()
-
# end wxGlade
-
-
def zooey(self, event):
-
import time
-
time.sleep(2)
-
pygame.mixer.music.load(event.GetItem())
-
pygame.mixer.music.play()
-
-
-
# end of class MyFrame2
-
-
-
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.tree_ctrl_1 = wx.TreeCtrl(self, -1, style=wx.TR_HAS_BUTTONS|wx.TR_NO_LINES|wx.TR_EDIT_LABELS|wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_HIDE_ROOT|wx.TR_ROW_LINES|wx.TR_DEFAULT_STYLE|wx.NO_BORDER)
-
-
self.__set_properties()
-
self.__do_layout()
-
-
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.boogienights, self.tree_ctrl_1)
-
# end wxGlade
-
-
root = self.tree_ctrl_1.AddRoot('Home')
-
ET = self.tree_ctrl_1.AppendItem(root, "Music")
-
-
artist_list = os.listdir('music')
-
for i in artist_list:
-
self.tree_ctrl_1.AppendItem(ET, i)
-
-
def __set_properties(self):
-
# begin wxGlade: MyFrame.__set_properties
-
self.SetTitle("frame_1")
-
self.tree_ctrl_1.SetBackgroundColour(wx.Colour(255, 255, 255))
-
# end wxGlade
-
-
def __do_layout(self):
-
# begin wxGlade: MyFrame.__do_layout
-
sizer_1 = wx.BoxSizer(wx.VERTICAL)
-
sizer_1.Add(self.tree_ctrl_1, 1, wx.EXPAND, 0)
-
self.SetSizer(sizer_1)
-
sizer_1.Fit(self)
-
self.Layout()
-
# end wxGlade
-
-
def boogienights(self, event): # wxGlade: MyFrame.<event_handler>
-
self.Hide()
-
frame_2 = MyFrame2(None, -1, "")
-
frame_2.Show()
-
# end of class MyFrame
-
-
if __name__ == "__main__":
-
app = wx.PySimpleApp(0)
-
wx.InitAllImageHandlers()
-
frame_1 = MyFrame(None, -1, "")
-
app.SetTopWindow(frame_1)
-
frame_1.Show()
-
app.MainLoop()
-
-
-
everything works up to when it's time to play an mp3 file. as you can see, i have a TreeCtrl that lists the items in a folder. However, as you know, when you enter a new folder with an ipod it slides over to a new screen, so i had to have a go at that.. anyway, when it's time for pygame to play a song i get a seg fault (i expected as much).
what i'm trying to have the program do is...when it opens up that next frame (I haven't actually added the ipod-folder-slide effect yet..) and lists the contents and i click a file, i want pygame to play that file. the problem is that i have to idea how to tell pygame which file the user has selected...
all help would be greatly appreciated.
Oct 28 '07
10 2080 bartonc 6,596
Recognized Expert Expert
i'll check out pygtk to see if i like it better than wx..
IMO, GTK is not as well structured as wx. We have on member on these boards who is required to use GTK and wishes he xould switch to wx. I've had a look at GTK's class structure and didn't see anything that I liked.
I also prefer Boa Constructor over wxGlade for GUI generation.
Just my two cents worth.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: AnsNum |
last post by:
hello,
when I start this program, the movie doesn't play smoothly, anybody has an
idea ?
(I use windowsXP)
import pygame
from pygame.display import flip
from pygame.locals import *
pygame.init()
|
by: Erik Bethke |
last post by:
Hello All,
I am having a great time with python and pygame, and last night I took
a long look at the wxPython demo. I think that rocks as well.
So now, my question is do wxPython and PyGame work together?
How is the windows event loop managed? How is the display window
managed?
|
by: Marian Aldenhövel |
last post by:
Hi,
I am trying to make pygame play music on windows. This simple program:
import pygame,time
pygame.init()
print "Mixer settings", pygame.mixer.get_init()
print "Mixer channels", pygame.mixer.get_num_channels()
pygame.mixer.music.set_volume(1.0)
pygame.mixer.music.load('file1.mp3)
|
by: boyanpn |
last post by:
I a newbie in python so excuse me if my question sounds stupid or
something :(
I wonder if my web host suports python (with pygame), if I download
game from www.pygame.org and upload it to my site, could users access
to it with browser and play game ?
|
by: crystalattice |
last post by:
I'm making a GUI for a console-based program I just wrote. I figured
it would be mostly straight forward to convert it over in wxPython but
now I'm confused.
In my console program, I have __init__ making the dictionaries et al.
and then my methods will populate them. However, when I use wxGlade
under SPE to make the GUI, wxGlade makes it's own __init__. I know not
to add anything to this section because it's written over everytime I...
| |
by: zswartz |
last post by:
Hi All, I've been stuck here for some time now and can't figure this out. If ANYONE can assist me, that would be AMAZING!!
I have Windows XP, with Python 25 and Pygame for python 25. I am also coding this in Eclipse
-----------------------------------------
My music files are:
D:\My Documents\School Work\Comp 523\Projects\MediaPlayer\MediaPlayer\src\MediaPlayer\Music\one.mp3
-----------------------------------------
My Project files...
|
by: joshuabraham |
last post by:
os version =windows xp
hi guys i'm having problems using pygame the following code just does not seem to work.
clock=pygame.time.Clock()
while True:
sound1.play()
clock.tick(60)
pKeys = pygame.key.get_pressed()
Eves=pygame.event.get()
villian.face()
villian.hert()
|
by: globalrev |
last post by:
http://www.pygame.org/docs/ref/mixer.html
import pygame
#pygame.mixer.init(frequency=22050, size=-16, channels=2,
buffer=3072) //it complained abiout words=
so i guess its only the nbrs should be there//
pygame.mixer.init(22050, -16, 2, 3072)
pygame.mixer.music.load("example1.mp3")
|
by: dynamo |
last post by:
hi guy,when i run my program which contains the following portion of code in the mainloop
clock=pygame.time.Clock()
while True:
sound1.play()
clock.tick(60)
pKeys = pygame.key.get_pressed()
Eves=pygame.event.get()
villian.face()
villian.hert()
if Eves and pKeys:
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |