Kruptein 15 Posting Whiz in Training

Okay I was able to solve it with Main.Hide(self)

Kruptein 15 Posting Whiz in Training

Okay I made the second frame an other class and I was able to show the second Frame as followed:

def new_game(self, event): # wxGlade: Main.<event_handler>
	Main(self,-1).Show(False)
        Game(self,-1).Show(True)

the Game window shows, but the Main window does not hide.

Kruptein 15 Posting Whiz in Training

Okay I started using wxGlade which is better as Glade,
but now I have one problem, I can't find a way to hide my Frame and show an other frame.

class Main(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: Main.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.p1name = wx.StaticText(self, -1, "Player 1 Name:", style=wx.ALIGN_CENTRE)
        self.p1entry = wx.TextCtrl(self, -1, "")
        self.p2name = wx.StaticText(self, -1, "Player 2 Name:", style=wx.ALIGN_CENTRE)
        self.p2entry = wx.TextCtrl(self, -1, "")
        self.moneystart = wx.StaticText(self, -1, "Money:", style=wx.ALIGN_CENTRE)
        self.moneyentry = wx.TextCtrl(self, -1, "")
        self.newgamebutton = wx.Button(self, -1, "start new game")
        self.newgameinfo = wx.StaticText(self, -1, "Money: the ammount of\n money each player gets\n at the start")
        
        # Menu Bar
        self.menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.NewId(), "New", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(wx.NewId(), "open", "", wx.ITEM_NORMAL)
        self.menubar.Append(wxglade_tmp_menu, "File")
        wxglade_tmp_menu = wx.Menu()
        self.menubar.Append(wxglade_tmp_menu, "Help")
        self.SetMenuBar(self.menubar)
        # Menu Bar end

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.new_game, self.newgamebutton)
        self.Bind(wx.EVT_MENU, self.new_game, id=-1)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: Main.__set_properties
        self.SetTitle("frame_1")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: Main.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.GridSizer(4, 2, 0, 0)
        grid_sizer_1.Add(self.p1name, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.p1entry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.p2name, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.p2entry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.moneystart, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.moneyentry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.newgamebutton, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        grid_sizer_1.Add(self.newgameinfo, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
        sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

    def new_game(self, event): # wxGlade: Main.<event_handler>
        wx.Frame("frame_2").Show(True)

I try to show a frame in the function new_game,
but I can't fin a way I tried self.frame_2.Show, etc... but it seems that wxglade does not declare …

Kruptein 15 Posting Whiz in Training

Okay, it's good someone tells me at this point pygtk isn't that usefull,
so wxpython is better supported on both windows and linux?

I will give it a try

Kruptein 15 Posting Whiz in Training

1. Is it possible to draw a border line around a table and/or a cell
2. Is it possible to draw a color to the background of a label.
2bis If not, is there an other element that can have background colors
3 How can I set the default height and width from a window(toplevel).
I tried to use default height and default width
(sounds quit logic) but the window always stays in the same
small format

I hope someone knows the answer at one of these questions.

Kruptein 15 Posting Whiz in Training

with the function:
list(string)
you put every letter from the string in a list,
I want to put each 2 letters in a list
so If I had the string: ThisIsATestt

I want to get a list:

(There will never be a letter alone, so you don't have to think about that)

Kruptein 15 Posting Whiz in Training

okay I tried to make a reverse of finding the num value of a letter bu it returns in an error :f

Traceback (most recent call last):
File "/home/darragh/Bureaublad/t.py", line 15, in <module>
numtolet('A')
File "/home/darragh/Bureaublad/t.py", line 6, in numtolet
letters
TypeError: list indices must be integers, not tuple

def numtolet(num):
	letters['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
	nummers = []
	for i in range(1,25):
		nummers.append(i)
	pos = nummers.find(num)
	poss = letters.find(pos - 1)
	return poss
Kruptein 15 Posting Whiz in Training

Okay that was quit stupid :f

Kruptein 15 Posting Whiz in Training

I need to split a float in 2, but the split function doesnt work with floats...
What is an alternative for this?

If I have 2.4 I want to get 2 and 4
In math you've got a function fpart and ipart, but I don't know this is possible in python...

Kruptein 15 Posting Whiz in Training

That's the one I needed! thanks

Kruptein 15 Posting Whiz in Training

hm okay, but in that case I have to make a difference between caps and lowercase letters,... but I will work with that.

Kruptein 15 Posting Whiz in Training

No I don't mean that, that would be stupid.
every letter of the alphabet represents a number
a = the first letter = the first number = 1
b = the second letter = the second number = 2
...
so if I did:

letval(a) #=1
letval(g) #=7 because g is the seventh letter in the alphabet
Kruptein 15 Posting Whiz in Training

Is there a built-in function to give the value of a letter?

what I mean is
a=1
b=2
c=3
d=4
e=5
f=6
...

something like letval(a) would give me 1

Kruptein 15 Posting Whiz in Training

You can simply do this with php, and include some ajax to make everything easier for the user, I don't know anything about ajax :p
with php you will have to make a html form like this:

<form action='example.php' method='post'>//or an other page or get
<input type='text' name='txt'></form>

example.php
Here you will need to do some queries to get a product from the database and show it to the user.

Kruptein 15 Posting Whiz in Training

beautifull,

and what do you mean?

Kruptein 15 Posting Whiz in Training

I thought so, because I will need todo a query to get which nation has which region and then I have to color the picture.
The regions can change every minute from nation, so everytime the page is called, the world map will be colored a bit different as before.

you get my point?

Kruptein 15 Posting Whiz in Training

I got a table that is made up as followed: region_id,...nation_id the regions are countries, the nations are names users choose.
I want to have a world map showing which nation has which region,
Is this possible?
I'm not sure how to do this, but maybe something with <map> and <area>???

Kruptein 15 Posting Whiz in Training

Yes i did that first, but it uses so many of my web speed, but I will give it a second try...

Kruptein 15 Posting Whiz in Training

No I don't want the image to be vertically repeated because this would have a verry ugly effect (it's an image, not a pattern)
I want the image to be stretched vertically is this possible?

image = 1090x587

Kruptein 15 Posting Whiz in Training

In my browser(opera), my background image takes up the full height off the screen, but on my friends(firefox) there appears a large black banner beneath it (black because that is the bgcolor)

I give you the css hopefully you guys can help me.

body {
color:#C00;
background-color:#000;
background-image:url('../background.jpg');
background-repeat:no-repeat;
background-position:top;
height:100%;
}
Kruptein 15 Posting Whiz in Training
Kruptein 15 Posting Whiz in Training

Thanks alot :) maybe I indeed shouldnt use the progressbar in this case.

Btw: OFCOURSE i used google, but the infog I found wasn't relevant on my case, or it was bad explained.
Otherwise I wouldn't ask it here!

Kruptein 15 Posting Whiz in Training

I just need to know how the pygtk progressbar works, on the internet I can't find any good info about it ...

Kruptein 15 Posting Whiz in Training

Go to users
and change privileges..

Kruptein 15 Posting Whiz in Training

yeah but u can get the info with php when the page loads.

Yes but that wasn't the question..

Kruptein 15 Posting Whiz in Training

Okay that is probably right, but now it says I don't have permission, which is right because I made those files as root, but if I do sudo for ... then it says unknown command for...

What to do know?

Kruptein 15 Posting Whiz in Training

What am I doing wrong?

for filename in /home/darragh/public_html/test/*
do
 sed -i 's/..\/config/.\/config/g'
done;

It just gives me: sed: No input files

Kruptein 15 Posting Whiz in Training

How should others be possible to modify it?

Kruptein 15 Posting Whiz in Training

try

if($_POST['save_msg'])
Kruptein 15 Posting Whiz in Training

Is there really no one who knows how to use the pygtk progressbar?

Kruptein 15 Posting Whiz in Training

You are using a certain function called mail()

$sent = @mail(...)

This is a built-in function off php, but can be turned off, to check if it is turned off, do phpinfo() and check if it is enabled.
I don't know what the @ is doing in front of the mail, I just use it without...

Kruptein 15 Posting Whiz in Training

Mysql can't do an action on itself. It needs an instruction.
You can though, solve this by using a php cron script.
a cron script is a script that auto loads each x minutes/hours/days/months ...
You can choose when.

Kruptein 15 Posting Whiz in Training

No we use <> instead..

INSERT INTO bookingsA(task,DATE)
VALUES ('test','2009-01-01')
WHERE DATE <> tableB.DATE;
Kruptein 15 Posting Whiz in Training

Are you sure, you can use the mail function?
some servers block it fort spam reasons.

Kruptein 15 Posting Whiz in Training

Force the vote row to be not null, and set the default value to zero.

Kruptein 15 Posting Whiz in Training

I agree with cwarn23

Kruptein 15 Posting Whiz in Training

That is better as the previous version, but does it work?

Kruptein 15 Posting Whiz in Training

You always have to give an other name:
you are doing everywhere: (...) As P

Kruptein 15 Posting Whiz in Training

Opera is the best :p
I thought, "lets see how opera is", I downloaded it and I fell in love with it,
I only use ff for some plugins and that's it.
There is a browser war, but I hope IE will lose it (and safari too)
and Opera Chrome and FF will win it together. End of the story

Kruptein 15 Posting Whiz in Training

I had once the same problem, in FF everything was messed up. I've solved it by instead of using: width: 150px doing width: 145px
Try to do some pixels of the width, heigth and say if it still occurs.

Kruptein 15 Posting Whiz in Training

Did you check the optimization site almostbob gave you?
the site

It is really handy, I used it for mine too

Kruptein 15 Posting Whiz in Training

in one query:

UPDATE table SET field3 = field1-field2

I think this should work.

(everytime you update/change a value of field1/field2 you will have to do this query, mysql can't do this automatic..)

Kruptein 15 Posting Whiz in Training

You can actualy doing multiple inner joins after each other:

SELECT P.post_id, P.post_content, P.post_date, sum(T.vote_tally) as total_vote
		FROM votes as T
		INNER JOIN (
		SELECT *
		FROM posts tp
		GROUP BY tp.post_id
		) as P on P.post_id = T.post_id
                        INNER JOIN (SELECT ...) as ... on ... = ...
                        INNER JOIN ...
		GROUP by P.post_ id

I hope this helps

Kruptein 15 Posting Whiz in Training

I would use sessions instead actually, they are more secure as cookies in my opinion, you can read all data cookies send in your browser, but sessions are a bit harder to read becuase they are encoded. They are actually encoded cookies, ...

Kruptein 15 Posting Whiz in Training

All of the following work:

<?php
require('./index.php')
require_once('./index.php')
include('./index.php')
include_once('./index.php')
?>
Kruptein 15 Posting Whiz in Training

It's sure that google doesn't read iframes, but I can't say they think it are viruses, I also used iframes a lot, but people told me it was a bad habbit.

Solution: Use require(_once) or include(_once) instead of iframes, google will read those! and you don't see the difference.

I hope this will help you :)

Kruptein 15 Posting Whiz in Training

Can someone help me with this, if I run ftp, the page is downloaded and showed well, but the progress bar only shows 100% and doesn't progress at all..

def progress_timeout(pbobj):
	        # Calculate the value of the progress bar using the
       		# value range set in the adjustment object
       		new_val = pbobj.pbar.get_fraction() + 0.01
       		if new_val > 1.0:
       			new_val = 0.0
		        # Set the new value
		        pbobj.pbar.set_fraction(new_val)

	    	# As this is a timeout function, return TRUE so that it
		# continues to get called
		return True


	def ftp(self, w, date):
        	self.win = gtk.Window(gtk.WINDOW_POPUP)
	        self.win.set_resizable(True)
	        self.win.set_title("ProgressBar")
	        self.win.set_border_width(0)
	        fvbox = gtk.VBox(False, 5)
	        fvbox.set_border_width(10)
	        self.win.add(fvbox)
	        fvbox.show()
	        # Create a centering alignment object
        	align = gtk.Alignment(0.5, 0.5, 0, 0)
        	fvbox.pack_start(align, False, False, 5)
	        align.show()
        	# Create the ProgressBar
        	self.pbar = gtk.ProgressBar()
        	align.add(self.pbar)
        	self.pbar.show()
        	# Add a timer callback to update the value of the progress bar
        	self.timer = gobject.timeout_add (100, self.progress_timeout, self)
	        self.win.show()
		self.progress_timeout
		ftp = FTP(self.host)
		percent = 0.1
 		self.pbar.set_text("10%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		ftp.login(self.usr,self.pswd)
		percent = 0.2
               	self.pbar.set_text("20%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		ftp.cwd(self.dir)
		percent = 0.3
               	self.pbar.set_text("30%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		retr = 'RETR ' + self.ftpfile
		ftpp = self.location + '/ftp.ded'
		ftp.retrbinary(retr, open(ftpp, 'w').write)
		percent = 0.4
               	self.pbar.set_text("40%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		ftp.quit()
		percent = 0.5
               	self.pbar.set_text("50%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		txt = ''
		f = open(ftpp, 'r')
		percent = 0.6
               	self.pbar.set_text("60%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		for line in f.readlines():
			txt = txt + line
			self.textbuffer.set_text(txt)
		f.close()
		percent = 0.9
               	self.pbar.set_text("90%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		self.cmdbuf.set_text('Opened: ftp.ded')
		percent = 1.0
               	self.pbar.set_text("100%")
                self.pbar.set_fraction(percent)
		self.progress_timeout
		self.opnd = 'ftp.ded'