473,766 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hiding console window

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
6 5484
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
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
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
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

"Lucas Raab" <py*********@ho tmail.com> wrote in message
news:Xk******** *********@newsr ead3.news.atl.e arthlink.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.in it()
#Load and play sound1
pygame.mixer.mu sic.load('C:/sound1.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play hazards of retreating
pygame.mixer.mu sic.load('C:/hazards_of_retr eating.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play bring it on
pygame.mixer.mu sic.load('C:/bring_it_on.mp3 ')
pygame.mixer.mu sic.play()
sleep()
#Load and play freaked by flood
pygame.mixer.mu sic.load('C:/freaked_by_floo d.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play grunty thirst
pygame.mixer.mu sic.load('C:/grunty_thirst.m p3')
pygame.mixer.mu sic.play()
sleep()
#Load and play joe has lost it
pygame.mixer.mu sic.load('C:/joe_has_lost_it .mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play the french grunt
pygame.mixer.mu sic.load('C:\th e_french_grunt. mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play stacker e3 outtake2
pygame.mixer.mu sic.load('C:\st acker_e3_outtak e2.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play poor running anatomy
pygame.mixer.mu sic.load('C:\po or_running_anat omy.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play bring it on
pygame.mixer.mu sic.load('C:\br ing_it_on.mp3')
pygame.mixer.mu sic.play()
#Quit playing and close pygame
pygame.mixer.qu it()
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
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.in it()
#Load and play sound1
pygame.mixer.mu sic.load('C:/sound1.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play hazards of retreating
pygame.mixer.mu sic.load('C:/hazards_of_retr eating.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play bring it on
pygame.mixer.mu sic.load('C:/bring_it_on.mp3 ')
pygame.mixer.mu sic.play()
sleep()
#Load and play freaked by flood
pygame.mixer.mu sic.load('C:/freaked_by_floo d.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play grunty thirst
pygame.mixer.mu sic.load('C:/grunty_thirst.m p3')
pygame.mixer.mu sic.play()
sleep()
#Load and play joe has lost it
pygame.mixer.mu sic.load('C:/joe_has_lost_it .mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play the french grunt
pygame.mixer.mu sic.load('C:\th e_french_grunt. mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play stacker e3 outtake2
pygame.mixer.mu sic.load('C:\st acker_e3_outtak e2.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play poor running anatomy
pygame.mixer.mu sic.load('C:\po or_running_anat omy.mp3')
pygame.mixer.mu sic.play()
sleep()
#Load and play bring it on
pygame.mixer.mu sic.load('C:\br ing_it_on.mp3')
pygame.mixer.mu sic.play()
#Quit playing and close pygame
pygame.mixer.qu it()
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6616
by: Marc | last post by:
Hi all, I know that to hide a console normally you simply change the extension from .py to .pyw. That's simple enough. However I can't seem to accomplish the same thing after freezing the program. I've tried building the setup file with the python script as a .pyw file, but it crashes and doesn't give me a reason. This is of course because the debug window doesn't open, so you don't know what happened (ahh, the irony).
4
4470
by: Matthew Maylin | last post by:
I'm trying to call a external program from another. My main program is a GUI buildin borland c++ builder, and my sibbling is compiled Matlab code. I would like to call to the program, passing arguments and suppress the msdos window from popping up. I have had success with system( ) and spawnl( ) but cant seem to get the external program to just run in the background.
1
5387
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
17
2917
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that when the Poodle is upcast to the Dog (in its wildest dreams) it then says "bow wow" where the bernard always says "woof" (see code). Basically, it appears that I'm hiding the poodle's speak method from everything except the poodle. Why would I...
4
3165
by: shuisheng | last post by:
Dear All, Would you please give me a hint on how to hide the console window opened by _popen? I appreciate your kind help! Shuisheng
0
1511
by: amessbee | last post by:
I am facing a problem while creating/executing a process in C. I am using old fork/exec mechanism. The problem is: I want to hide the console window of the app i am instantiating. Remember i am instantiating a console application from a GUI application. Is this possible? How? Comments are welcome here or at this page. http://mudassir.livejournal.com/22806.html thanks!
10
6348
by: Stephany Young | last post by:
When one uses the System.Diagnostics.Process.Start method to launch a common or garden Console application, one can set the WindowStyle property of the StartInfo object to ProcessWindowStyle.Hidden so that the window for the Console application is not visible. However, when using some of the 'advanced' properties of the StartInfo object, like Username, Password and Domain, the WindowsStyle property of the StartInfo object is ignored....
3
13860
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the application is run in Debug mode. However, I just can't get that to work. I'm using Visual Studio 2005. I've confirmed that my application is compiled as a console application, and that I'm running in Debug mode. To investigate this issue, I've reduced...
5
10776
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Dear all, I'd like to know if there is any method to minimize command mode window when a console program is running. In my case, there are several console programs which run periodically in server. Now, every console program instance will open a command mode window and they occupy the whole screen. I want to minimize all of them and maximize it if neccessary by manual. Is it possible and how to do it? I'm using VB.NET 2005. ...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
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...
1
9959
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,...
0
9837
tracyyun
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...
0
6651
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();...
0
5279
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...
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
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...

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.