473,659 Members | 3,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determining an operating system's default browser

Is there a python module which can determine an operating system's
default web browser application.

I would like to use it in the following context: I have a GUI
application where all the documentation is written as html pages. I
wish to have these html help pages open in the default browser when
selected from the application's Help menu

If python can determine the path to the default browser, I can then just
spawn it.

Regards,

John McMonagle


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Feb 9 '06 #1
11 5620
You don't have to determine it. Just os.startfile('p age1.html')
and let the OS figure it out.

-Larry Bates
John McMonagle wrote:
Is there a python module which can determine an operating system's
default web browser application.

I would like to use it in the following context: I have a GUI
application where all the documentation is written as html pages. I
wish to have these html help pages open in the default browser when
selected from the application's Help menu

If python can determine the path to the default browser, I can then just
spawn it.

Regards,

John McMonagle

Feb 10 '06 #2
Larry Bates wrote:
You don't have to determine it. Just os.startfile('p age1.html')
and let the OS figure it out.


Note that this only works on Windows.

Feb 10 '06 #3
On Thu, 2006-02-09 at 17:53 -0600, Larry Bates wrote:
You don't have to determine it. Just os.startfile('p age1.html')
and let the OS figure it out.


Works great for Windows - not available on Unix though.

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Feb 10 '06 #4
John McMonagle wrote:
Is there a python module which can determine an operating system's
default web browser application.

I would like to use it in the following context: I have a GUI
application where all the documentation is written as html pages. I
wish to have these html help pages open in the default browser when
selected from the application's Help menu

If python can determine the path to the default browser, I can then just
spawn it.

Regards,

John McMonagle

I think the htmlview command is used for this purpose (displaying html
documentation of applications) on many Linuxes. So you could try
os.system('html view'). Given the variety of Unixes (and even Linuxes)
out there this is not a general solution.

So I would try htmlview first. If it does not work, the program could
ask the user for his favourite browser the 1st time he looks at docs,
and save this to a configuration file.
Feb 10 '06 #5

John McMonagle wrote:
Is there a python module which can determine an operating system's
default web browser application.

I would like to use it in the following context: I have a GUI
application where all the documentation is written as html pages. I
wish to have these html help pages open in the default browser when
selected from the application's Help menu

If python can determine the path to the default browser, I can then just
spawn it.

The module webrowser module does this - and I use it for exactly this
purpose. :-)

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
Regards,

John McMonagle


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


Feb 10 '06 #6
John McMonagle wrote:
On Thu, 2006-02-09 at 17:53 -0600, Larry Bates wrote:
You don't have to determine it. Just os.startfile('p age1.html')
and let the OS figure it out.


Works great for Windows - not available on Unix though.


Take a look at the desktop module for similar functionality for KDE,
GNOME and the Mac OS X desktop environment (as well as Windows, of
course):

http://www.python.org/pypi/desktop

Paul

Feb 10 '06 #7
John McMonagle <jo****@velseis .com.au> wrote:
Is there a python module which can determine an operating system's
default web browser application.


http://docs.python.org/lib/module-webbrowser.html

--
\S -- si***@chiark.gr eenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
Feb 10 '06 #8
On 10 Feb 2006 03:51:01 -0800, Paul Boddie <pa**@boddie.or g.uk> wrote:
John McMonagle wrote:
On Thu, 2006-02-09 at 17:53 -0600, Larry Bates wrote:
> You don't have to determine it. Just os.startfile('p age1.html')
> and let the OS figure it out.


Works great for Windows - not available on Unix though.


Take a look at the desktop module for similar functionality for KDE,
GNOME and the Mac OS X desktop environment (as well as Windows, of
course):


Note that those do not, of course, work on all Unices.

On my machines, there is One Correct Way of doing these things, and that's
to look in the MIME support/configuration files (~/.mailcap, and so on),
first for the user, then system-wide. Something there might tell you what
program should handle text/html content.

This mechanism is widespread under Unix, I think ... but I don't know if
there is a general interface to it, or a Python interface.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyn dns.org> R'lyeh wgah'nagl fhtagn!
Feb 11 '06 #9
Jorgen Grahn wrote:

[desktop module]
Note that those do not, of course, work on all Unices.
Correct: they work only for the stated desktop environments.
On my machines, there is One Correct Way of doing these things, and that's
to look in the MIME support/configuration files (~/.mailcap, and so on),
first for the user, then system-wide. Something there might tell you what
program should handle text/html content.
Indeed. Thanks for reminding me about mailcap/metamail - I used them in
a project about ten years ago, and I suppose not having any
opportunities to use them in the intervening period probably pushed
them to the back of my mind.
This mechanism is widespread under Unix, I think ... but I don't know if
there is a general interface to it, or a Python interface.


Here's an example:

import mailcap
command, entry = mailcap.findmat ch(mailcap.getc aps(), "text/html")

Here's another more comprehensive set of examples:

http://effbot.org/librarybook/mailcap.htm

Sadly, when considering my KDE desktop's default browser, inquiring the
application for HTML files yields Mozilla Firefox from my mailcap file.
What I've discovered is that the issue of an URL-opening application is
often quite separate from an appropriate application to open a file of
a given type. Perhaps I should call desktop.open something like
desktop.urlopen instead, since that name arguably describes the purpose
of the function more accurately.

Paul

Feb 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
5163
by: Dr.Tube | last post by:
Hi there, I have this web site (www.DrTube.com) which has the following DTD: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> which switches Mozilla to standards compliance mode as I can confirm myself. How can I check whether IE6 and Opera do so too? TIA Regards Xavier van Unen.
3
523
by: Ian Rowland | last post by:
Is there a way, using managed code, to determine the Service Pack of the OS without resorting to registry calls? OSVersion doesn't give this information. It seems the only way is to use the Win32API GetVersionEx!
18
4920
by: Robert | last post by:
Hi! I was wondering if the was any way to determine the state of the caps lock key, on or off. Of course I can capture the key events and see whether the caps lock is pressed, but that does not help. I have seen some example that looks at the characters entered in an input field to determine if the caps lock is on, but I was wondering if something is possible that is a bit more immediate to report the caps
4
2056
by: Rémi | last post by:
Question: How can you determine the character set used by a webpage you built? My understanding of the issue is that the character set used by an HTML file (or any other file, for that matter) depends on your own system, and the encoding used by it; you cannot randomly insert a <META HTTP-EQUIV="Content-Type" content="text/html; charset=xxx-1234-567">
23
52673
by: PW | last post by:
Hi, I'd like to close a recordset and set the database to nothing if a recordset is open if an error has occured. Leaving a recordset open and a database open isn't a good idea, right? Thanks, -paul w
19
2123
by: catmansa | last post by:
Is there anyway to determine the present pixel height & width size of a open browser window? :)
1
2354
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Dear Support, I'm not an ASP programmer, however so far by searching the web, I have created this working code: <html> <body> <p> <p> <b>School IP address:</b>
3
1525
Logan1337
by: Logan1337 | last post by:
Hi. I know about System.Diagnostics.Process.Start( url ) to launch a url in the default web browser, but I'm wondering if it's possible to actually get a path to the actual executable that is set as the default browser. In particular, I want to grab this file's icon to use in a menu item. Logan
4
2403
by: David C. Barber | last post by:
my.computer.printers.defaultprinter doesn't exist in 2005, despite the plethora of examples still out on the web detailing its use. So how can I determine a person's default printer using ASP 2? Thanks!
0
8428
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
8851
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...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
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
7356
agi2029
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...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
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
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.