scru 909

Hey I did what you said and I learnt how to use the resources. I like how my images are now globally available, and don't have to use filenames which can lead to problems.

Thanks...and I'm beginning to really like this language after all...

scru 909

Thanks guys. Do you think buying one of those books would be a good investment? (seeing I'm not a working man, I'm still in college)

Apparently the one by Jeffery Suddeth is the only one available to me (from Amazon, those on Microsoft Press aren't being sold anymore O.o).

One more thing, you said you have a huge library, do you have Microsoft Visual C# Programming for the absolute Beginner"? The reason I ask is because I own the coresponding one for python (just replace the MSVC#) and it didnt teach me everything I know, but it taught me enough to feel comfortable with the language...also the approach was kinda fun.

So do you know if MSVC# is anything like that?

Anyway thanks all you guys for helping this guy figure out how to go about learning a spanking new language.

P.S. That intellisense thing is pretty awesome huh???;)

scru 909

quick question. Can I use Tkinter and wxpython in the same app? (See i built this splash screen class in Tkinter --doesn't use buttons, but does a lot of work (loading images/files/wat not)).

If not, is there a way to remove the title bar and border in wxpython like [code=python]root.overideredirect(1)[/code]does in Tkinter?

scru 909

nevermind...i was using overridedirect instead of overideredirect....silly me... (thats why im a big fan of underscores...heh heh)

scru 909

This does not work for me, I get:
AttributeError: overridedirect

scru 909 Posting Virtuoso


I need a way to make an image as a background for a window, and still be able to put buttons and other controls on top of it. I even tried using wxPython's wxPanel, but it proved a real pain because I found the documentation very sparce...:sad: (google didn't even help).

Is there anyway I can do this? I've heard about the canvas but I have no idea how to use this...


scru 909 Posting Virtuoso

I might as well back up and start from the very top.

Does anybody know the best way for me to learn this language (from python), because I none of the tutorials I have tried work for me (I feel like I'm moving backwards here, and that's unnerving).


any suggestions on how I should learn this?

..I'm going back to python for now.

scru 909

yes write and read

scru 909 Posting Virtuoso

So here's the deal. I learned to program with python, and C# is my second step up the ladder. I'm currently learning the language by making a Sudoku game (just porting over the code from python..nothing fancy).

So I ran into a dead end just now...I know how to manipulate data files {*.dat) in python, to store objects/arrays/ etc. How is this done in C#? I need a quick way to open a file, and put/get two objects in/from it.

P.S. is shelving available in C# as well, because something like that is what I'm talking about. (It says somewhere in the python docs or something that shelving[what I'm used to using] is domething from C, or C++[memory is foggy])

scru 909

Well im using VS IDE, but i want to the image to change back and forth when the mouse enters and leaves the button's space.

I have not learned how to use resource files. Is there a tutorial for this?

Anyway, i've gotten it to work using the full path as you said, and those other problems seem to be disappearing one by one (i've learned to configure my splash properly and how to show/hide my forms properly...well i think).

One more question though, i'm using vcsharp express 2005. Now that I've gotten it working using full-paths, does the compiler have an option or something to put all my external stuff into a resource file (or something similar) upon compiling? (make it easier for me without having to bother my head about how to use resource files...)

Thanks's actually going smoother now...

scru 909

Oh ok. But I was just thinking, if I were to give the program to a couple friends it might not work since they might store the program seperately....

Thank you, I'll get to it right away

scru 909 Posting Virtuoso

I was just wondering....

There is a python projects for the beginner in the Python section of the site...maybe you guys can do one here too?

Any readers are welcome to second this request..;)

scru 909

Am I authorised to post here?

This one should be nice-ish.

I'm sure you've heard of Sudoku? Well write a computer program that creates a sudoku game for the user. Try to be innovative in the program rules (tweak the sudoku game rules a little so that the program is fun to play, or maybe more challenging...nothing dratsic though that doesn't make it "sudoku" anymore).

I already started a very limited working console version that tries to generate a solved puzzle, and then plays the game by comparing the solved puzzle to a new grid created to store the user's input.
Scroll down to get the code...

Your objectives are simple(ah...not so much), and ranked by ease(the latter ones may really try you if you are a beginner):

  1. Currently, the program generates a very limited set of very easily solved puzzles(there is an obvious pattern that each and every puzzle follows). You are required to change the program so that it can read a puzzle from a data file.

  2. Create a Gui front end for this program and get rid of this ugly, tedious console prompt...after which, allow the user to input false/temporary entries in the available squares that they can erase at any time they choose. When you've done with that, to really polish your UI, allow the user the ability to undo a max of 10 moves by order in which they made them (this should be separate from the ability to delete temporary squares), HINT: ...

scru 909

ok, i just realised that error description i posted isnt helpful at told me that I can't call a destroyed object? something like that...

scru 909 Posting Virtuoso

Is there anything wrong with this code?
namespace RotnetSudoku
public partial class splash : Form
public splash()
fclsStartScreen frmStartscreen = new fclsStartScreen();
this.Visible = false;
Apart from the indentation?

When i run it ithe splash form doesn't close...Also, if i change [code=c#]this.Visible= false;[/code] to [code=c#]this.close();[/code], i get this error:

System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name: 'splash'."
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at RotnetSudoku.Program.Main() in D:\Documents and Settings\T\My Documents\Visual Studio 2005\Projects\RotnetSudoku\RotnetSudoku\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
:!: :sad: :mad:

scru 909 Posting Virtuoso

Apparently the ewase of programming has disappeared when I stopped using python.
btnPlay.BackgroundImage = Image.FromFile("\Images\playbtn_down.jpg");
Now I have the image in a Images folder...and I don't see why this doesn't work (from build [F5])....
this is making me very bitter......It's one of the many problems I've encountered since I started using this language (all unsolved). BTW...I'm using MS Visual C# 2005 Express for what its worth....guh

scru 909

Is there any reason why your array is so complex? You have a list containing a tuple containing a list containing several tuples containing lists.....

Anyway, try this (no guarantees, don't have an intepreter may also need to fix the indents):

def countchar(array, char="a", total=0):
for element in array: #indent-1
=False #indent-2. different from "array" above.
if array
for element_ in element:#indent-3
return total+countchars(element, char=char, total=total)#indent-4
for element in array:#indent-3
if element==char:#indent-4
return total#indent-3

You need to realise that i don't have access to an IDLE now to test this, so you're going to have to figure out the indentation on your own (use your discretion). Another thing, if the code crashes or something like that, you should use your discretion fix it if its a minor bug.

Logically, all it does is check if the array conatins another array. If it does, it checks if that array contains another array...and s on. Finally, when it reaches the last array, it checks if each element in that array is an "a", or whichever other character you may want to search for. This uses may be frowned upon if you hand it in for homework, or use it to check large arrays.

Happy coding...

scru 909

Sorry I took so long to respond

Here is my code:

[code= python]
import socket, cPickle, select, sys, threading, time
from ftplib import FTP

class Server(object):
def init(self):''
self.port = 30000
self.size = 1048576
self.threads = []
def set_socket(self):
self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server.bind((, self.port))
def run(self):
while running:
print "running server on "+get_ip()+" at port "+str(self.port)
inputready, outputready, exceptready =, [], [])
print "check 1"
for soc in inputready:
print "check 2"
if soc==self.server:
print "check 3"
cli = Client(self.server.accept())

    print "ggk"
    for cli in self.threads:

class Client(threading.Thread):
def init(self, (client, address)):
def run(self):
running = 1
while running:
data = self.client.recv(self.size)
if data:
self.client.send(["confirm", 0])

def get_ip():
while speech[0] != "\n":
return ip

def send_list(clients):
client_file=file("clients.dat", "w")
cPickle.dump(clients, client_file)
client_file=file("clients.dat", "rb")
ftp=FTP("", "rotnet_client", "rottwylaz")
<A href="ftp://ftp.storbinary("STOR">ftp.storbinary("STOR clients.dat", client_file)

def get_list():
ftp=FTP("", "rotnet_client", "rottwylaz")
<A href="ftp://ftp.retrbinary("RETR">ftp.retrbinary("RETR clients.dat", file("clients.dat", "wb").write)
data_file=file("clients.dat", "r")
return clients

def print_list():
for client in clients:
print "User at "+client[0]+" is connected at port", client[1]
class Printer(threading.Thread):
def init(self):
def run(self):


scru 909 Posting Virtuoso

I know I've been told before to use C++ sockets...and I will if this doesn't work out, but that was before I even knew python had sockets.

Now. The problem here if that my socket enabled program seems to work perfectly well on a LAN, but not over the internet (connection seems impossible). I suspect it may be the DSL modem setting its own local IPs ( etc).

I tried binding the server to the public ip of the modem(after parsing it from an FTP server's welcome message), but it refuses to do so and scolds me with a few lines of red.

The other thing I tried was to set up port forwarding on the router (not sure if I did it right though), but that didn't work.

So is there some way I can structure the code so that the connecting client can bypass the modem and get to my server? Or (and I know this may not be your expertise) is there someway I can force to modem to assign the public IP to my comp?...however dangerous that may be?

scru 909

Hey, that link that Jeff gave me, has information that works! My friends and I have been able to send messages and even files over the school LAN using python socket module. Now we're going to try it over the internet (I feel it should work, because it uses IP addresses)

So thanks Jeff. We are going to try it in python first (because its unbelievably easy), and then try C++ if that doesn't work out.

Thanks again for awesome help...i tell you this site is just great.

scru 909 Posting Virtuoso

Hi. SInce you guys were so helpful the last time around, I decided to ask a less pressing, but more casual questions.

My friends and I want to build a private p2p client (connects to our computers through this client to share files and do messaging), just for the heck of know, to see if we can.

So I'm thinking, can it be done easily/efficiently in python? Or what language might be best for this? Also, any good resources available as to where to start reading up on how to implement this (yes, I said reading up)?

Here's what we're looking for:

Possibly make it a bit private, or at least, make it only compatible with the client we build.

Remote access. It would be cool if it won't be bound to just the computers we own, but any computer we put the client on (we'd have authorisation of course)

We don't want to have to use an internet server, but have it decentralized over our computers. They just connect and talk.

Send files, and chat messages in real time

Maybe even be able to broadcast and receive multimedia to and from each other. (not a vital, but that would be really good)

I know this is sort of just re-inventing the wheel, but as I said it's really just to see if we can do it.

Also, you should know that we are willing so to learn anything we have to and will have a lot of patience ...

scru 909

Well in a couple weeks (after I finish my database project), Me and my friends are going to commence coding (or feeble attempts at) a private server and a client to go with it.

So...who wants to help? :P

and also, is python the best language for this? I am also open to learning other languages, but python and VB happen to be my languages of preference.

scru 909

WOOHOO! THanks you guys. I now have a working timer. The problem was that I mis-interpreted mawe's post and wrote my own self.update()....that didn't work. But it was from the last post that I got egged on that Tk objects have update methods, and I used it after [code=python]self.hourlbl["text"]=self.hh

etc....[/code] and it works just fine now.


scru 909

Well that doesn't work either. The same thing happens: all i see is the console window.

scru 909

Hey mawe. I take it I need to just write an update method with all the stuff that was there in it?

And yeah Jeff, it was that book. It's the one we use in school....well it's the one the school told us to take and go learn python on our own. It's sitting open on my printer to the livewires reference page right now, incidentally.

Well thanks guys for all your help. I'll try it when I get to work, cause I'm late for school right now. Let you know how it goes.

scru 909

humblest apologies.

Livewires based timer:

Te-je Rodgers
Counter module

from livewires import games, color

class Counter(games.Sprite):
"""My counter is a sprite."""
def init(self, screen, x, y,image, passer):
self.screen = screen
self.init_sprite(screen = screen, x = x, y = y, image=image)[0]
games.Text(screen=screen, x=200, y=20,, color = color.white, size=50)
games.Text(screen=screen, x=200, y=180, text="Press ENTER or F1 to stop",
color=color.white, size=20)


def close_timer(self):

    if self.hh<0:
        import last

def good(self):
def display_message(self):
    games.Message(screen = self.screen, x=200, y=100,
                  text=str(self.hh)+" : "+str(" : "+str(, size=100, after_death=self.good(),
                  color=self.col, lifetime=75)

def decrease_seconds(self):
    if self.hh>=0:
                if self.hh<0:
def moved(self):
    if self.screen.is_pressed(games.K_RETURN) or self.screen.is_pressed(games.K_F1) or self.screen.is_pressed(games.K_KP_ENTER):
    if self.hh==0 and and
    if self.count==75:

def start(passer):
root32=games.Screen(400, 200)
x=Counter(root32, 296, 139, sprite_image, passer)

Tkinter timer(not working at all):

Gamal Crichton
Teje's Counter

from Tkinter import *
import time
class Application(Frame):
def init(self,master,actname,time):
print time


def disp_widgets(self):
    #Uses labels to diaply time.
, font=("Arial, 32")

          text=self.hh, font=("Arial, 40")
, font=("Arial, 40")

, font=("Arial, 40")

    Button (self,
            ).grid(row=2,column=0,sticky=E, columnspan=3)

def show(self):
        print "Booooooooo!"
def aggregate(self): #This function is supposed to decrement the time
    for hours in range(self.hh, -1, -1):
        for minutes in range(, -1, -1):
            for seconds in range(, -1, ...

scru 909 Posting Virtuoso

Hi. I've just registered, but I'm not exactly new to here (i've been lurking as a guest). I'm trying to make a countdown timer based on a class that I created, which accepts hours, minutes, and seconds as parameters and counts them down to zero, will displaying them in a Tkinter window.

Now, I did start on it using Tkinter, but the Tkinter window just never appears (for some reason, I suspect this has something to do with the time.sleep() i use in my aggregate function, because everything else seems fine and when I the aggregate() function call, the window runs normally.

I managed to create a temporary fix using livewires, that instead of using time.sleep(), uses the mainloop() cycles to decide when to decrement a second (mainloop in livewires do a certain amount of cycles per second). The problem with this is that it isn't always accurate. That is, sometimes it goes too fast, and sometimes it goes too slow with the exact same FPS settings (I suspect this has to do with my CPU load or something...i'm not very skilled and I don't know a lot about these things).
Another problem with the livewires method is that while in Tkinter, I could just destroy() the timer window when the timer is through and call back the main window(I want the timer to quit, and open back the start screen when it is through), with this livewires version it just locks up when i tell it screen.quit() (The destroy() ...