By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,508 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,508 IT Pros & Developers. It's quick & easy.

Hiding console window

P: n/a
I'm looking to play a joke on a friend and I'm wondering if there's a way to
not show or hide the DOS console. My friend doesn't have python so I have to
compile it to an EXE.

TIA
Jul 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Lucas Raab wrote:
I'm looking to play a joke on a friend and I'm wondering if there's a way to
not show or hide the DOS console. My friend doesn't have python so I have to
compile it to an EXE.


Use py2exe to compile Python programs to EXEs.

You would need to define what "hide" means to you to get a useful answer
to the first part of the question. I would just click on the "close"
gadget in the upper right corner, if I wanted to "hide" a DOS console...

-Peter
Jul 18 '05 #2

P: n/a
Peter Hansen wrote:
Lucas Raab wrote:
I'm looking to play a joke on a friend and I'm wondering if there's a
way to
not show or hide the DOS console. My friend doesn't have python so I
have to
compile it to an EXE.

Use py2exe to compile Python programs to EXEs.

You would need to define what "hide" means to you to get a useful answer
to the first part of the question. I would just click on the "close"
gadget in the upper right corner, if I wanted to "hide" a DOS console...

-Peter

I think there is a way of telling py2exe that the program is a windows
exe, so you won't see the console. You just have to invoque the py2exe
help. If I'm not wrong the option should be "--help" or "-h"
Regards,
Josef

Jul 18 '05 #3

P: n/a
You can tell py2exe to make a windows exe by putting the line windows =
["yourscript.py"] in your setup.py script.
Example:
"""
# A setup script

from distutils.core import setup
import py2exe

setup(windows = ["yourScript.py"])
"""
What I'm wondering about now if there's a way to achieve the same for a
python script (instead of the .exe version of that script). --> I want
to double-click on a python Tkinter script and only see the GUI, not the
console window behind it. Does anyone know how to do this?

Regards,
Otto

Josef Meile wrote:
Peter Hansen wrote:
Lucas Raab wrote:
I'm looking to play a joke on a friend and I'm wondering if there's a
way to
not show or hide the DOS console. My friend doesn't have python so I
have to
compile it to an EXE.


Use py2exe to compile Python programs to EXEs.

You would need to define what "hide" means to you to get a useful
answer to the first part of the question. I would just click on the
"close" gadget in the upper right corner, if I wanted to "hide" a DOS
console...

-Peter


I think there is a way of telling py2exe that the program is a windows
exe, so you won't see the console. You just have to invoque the py2exe
help. If I'm not wrong the option should be "--help" or "-h"
Regards,
Josef

Jul 18 '05 #4

P: n/a
Otto Krüse wrote:
You can tell py2exe to make a windows exe by putting the line windows =
["yourscript.py"] in your setup.py script.
Example:
"""
# A setup script

from distutils.core import setup
import py2exe

setup(windows = ["yourScript.py"])
"""
What I'm wondering about now if there's a way to achieve the same for a
python script (instead of the .exe version of that script). --> I want
to double-click on a python Tkinter script and only see the GUI, not the
console window behind it. Does anyone know how to do this?


The extension should pyw instead of py!

Regards
Jorgen
Jul 18 '05 #5

P: n/a

"Lucas Raab" <py*********@hotmail.com> wrote in message
news:Xk*****************@newsread3.news.atl.earthl ink.net...
I'm looking to play a joke on a friend and I'm wondering if there's a way to not show or hide the DOS console. My friend doesn't have python so I have to compile it to an EXE.

TIA


In response to Peter's question, what I meant when I said hide was to hide
the console while running the program. Essentially, it would run in the
background. The application would run, but you wouldn't see any sign of it.
In response to Jorgen and Josef, unfortunately it didn't work. Here's the
code for it. It may be a little messy, but I wasn't aiming for perfection:

import pygame
import time

def sleep():
#Sleep for 5 minutes
time.sleep(300)
def play():
#Initialize pygame
pygame.init()
#Initialize mixer
pygame.mixer.init()
#Load and play sound1
pygame.mixer.music.load('C:/sound1.mp3')
pygame.mixer.music.play()
sleep()
#Load and play hazards of retreating
pygame.mixer.music.load('C:/hazards_of_retreating.mp3')
pygame.mixer.music.play()
sleep()
#Load and play bring it on
pygame.mixer.music.load('C:/bring_it_on.mp3')
pygame.mixer.music.play()
sleep()
#Load and play freaked by flood
pygame.mixer.music.load('C:/freaked_by_flood.mp3')
pygame.mixer.music.play()
sleep()
#Load and play grunty thirst
pygame.mixer.music.load('C:/grunty_thirst.mp3')
pygame.mixer.music.play()
sleep()
#Load and play joe has lost it
pygame.mixer.music.load('C:/joe_has_lost_it.mp3')
pygame.mixer.music.play()
sleep()
#Load and play the french grunt
pygame.mixer.music.load('C:\the_french_grunt.mp3')
pygame.mixer.music.play()
sleep()
#Load and play stacker e3 outtake2
pygame.mixer.music.load('C:\stacker_e3_outtake2.mp 3')
pygame.mixer.music.play()
sleep()
#Load and play poor running anatomy
pygame.mixer.music.load('C:\poor_running_anatomy.m p3')
pygame.mixer.music.play()
sleep()
#Load and play bring it on
pygame.mixer.music.load('C:\bring_it_on.mp3')
pygame.mixer.music.play()
#Quit playing and close pygame
pygame.mixer.quit()
pygame.quit()

#Start the program
play()

You may raise your eyebrows at the filenames, but as I said its a joke I'm
playing. The sound clips are based off the game Halo. Just fill in your own
files instead of mine.

TIA
Jul 18 '05 #6

P: n/a
If you generate the exe with py2exe, then you could do:

python setup.py py2exe -v -w

Where setup.py is the setup script where you specify the
python imports and your program modules. (see py2exe
documentation). The "-w" option was the option I was
talking before. I don't know if it produces the same
effect of the proposed solution by Otto. With this option,
you won't see a DOS console, however, I don't know if
it will hide the icon on the task bar. Try to call the script
on the "Startup" menu or with the "Scheduled Tasks" of
windows or perhaps you will have to do it from the
registry.
In response to Peter's question, what I meant when I said hide was to hide
the console while running the program. Essentially, it would run in the
background. The application would run, but you wouldn't see any sign of it. In response to Jorgen and Josef, unfortunately it didn't work. Here's the
code for it. It may be a little messy, but I wasn't aiming for perfection:

import pygame
import time

def sleep():
#Sleep for 5 minutes
time.sleep(300)
def play():
#Initialize pygame
pygame.init()
#Initialize mixer
pygame.mixer.init()
#Load and play sound1
pygame.mixer.music.load('C:/sound1.mp3')
pygame.mixer.music.play()
sleep()
#Load and play hazards of retreating
pygame.mixer.music.load('C:/hazards_of_retreating.mp3')
pygame.mixer.music.play()
sleep()
#Load and play bring it on
pygame.mixer.music.load('C:/bring_it_on.mp3')
pygame.mixer.music.play()
sleep()
#Load and play freaked by flood
pygame.mixer.music.load('C:/freaked_by_flood.mp3')
pygame.mixer.music.play()
sleep()
#Load and play grunty thirst
pygame.mixer.music.load('C:/grunty_thirst.mp3')
pygame.mixer.music.play()
sleep()
#Load and play joe has lost it
pygame.mixer.music.load('C:/joe_has_lost_it.mp3')
pygame.mixer.music.play()
sleep()
#Load and play the french grunt
pygame.mixer.music.load('C:\the_french_grunt.mp3')
pygame.mixer.music.play()
sleep()
#Load and play stacker e3 outtake2
pygame.mixer.music.load('C:\stacker_e3_outtake2.mp 3')
pygame.mixer.music.play()
sleep()
#Load and play poor running anatomy
pygame.mixer.music.load('C:\poor_running_anatomy.m p3')
pygame.mixer.music.play()
sleep()
#Load and play bring it on
pygame.mixer.music.load('C:\bring_it_on.mp3')
pygame.mixer.music.play()
#Quit playing and close pygame
pygame.mixer.quit()
pygame.quit()

#Start the program
play()

You may raise your eyebrows at the filenames, but as I said its a joke I'm
playing. The sound clips are based off the game Halo. Just fill in your own files instead of mine.

Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.