Compare commits

..

28 Commits

Author SHA1 Message Date
Bryan Petty
cd630ed42e This commit was manufactured by cvs2svn to create tag
'wxPython-0_5_4'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/wxPython-0_5_4@1552 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-01 00:17:53 +00:00
Robin Dunn
f4f55a0146 Added the missing EVT_LIST_ITEM_SELECTED and friends.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1551 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-01 00:17:53 +00:00
Robin Dunn
73c5ed3696 Added the missing EVT_LIST_ITEM_SELECTED and friends.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1550 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-01 00:11:43 +00:00
Vadim Zeitlin
9bd6a5037a this should be the file with the standard setting for wxWin compilation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1549 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-01 00:10:05 +00:00
Vadim Zeitlin
9f3362c440 more wxToolTip changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1548 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-01 00:05:03 +00:00
Vadim Zeitlin
cd4718483a some kbd handling fixes (some problems still persist)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1547 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-01 00:03:42 +00:00
Vadim Zeitlin
d311155fa2 unused message removed from event table
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:54:53 +00:00
Vadim Zeitlin
4fa688d8bc "selection changed" events are not generated any more when notebook
changes size


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1545 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:53:21 +00:00
Vadim Zeitlin
fff86b2918 wxControl::MSWNotify() handler calls wxWindow version if it doesn't
process the message (some messages were "missing" before due to this bug)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1544 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:52:39 +00:00
Vadim Zeitlin
fb99aca7f3 bug with Shift-TAB handling corrected
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1543 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:50:58 +00:00
Vadim Zeitlin
396bdd5ab1 very minor changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1542 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:49:57 +00:00
Vadim Zeitlin
3a19e16d18 wxToolTip for MSW implementation (it has several problems right now, but it
still works)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:38:10 +00:00
Vadim Zeitlin
6e0d9d4331 memory debugging using VC++ debug CRT works for DLL wxWin builds as well.
The relevant macros are now in include/wx/msw/msvcrt.h


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:32:58 +00:00
Vadim Zeitlin
06b5713445 wxStaticBitmap, wxStaticBox and wxPanel don't accept keyboard focus now
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:30:33 +00:00
Vadim Zeitlin
aeafc35493 by default the ctrl accepts keyboard input now (why wouldn't it?)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1538 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 23:28:58 +00:00
Harco de Hilster
f855e630cc internal browser creates temp file in current dir, safer if /tmp doesn't
exist


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1537 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 22:26:35 +00:00
Harco de Hilster
18b7950189 The obligatory Slashdot headlines retriever. Every self-respecting modern
widget library has to have one... I think it also makes a nice demonstration
of wxPython's capabilities.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1536 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 19:55:22 +00:00
Karsten Ballüder
cfad3750c3 Added (untested) support for sub-locales.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1535 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 19:38:40 +00:00
Julian Smart
8870c26ecb Added a few files; fixed some warnings and wxMotif compile problems
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 18:47:10 +00:00
Guilhem Lavaux
e2cad35228 * Some more on streams.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 16:56:04 +00:00
Julian Smart
0a240683ed Various small fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 13:58:17 +00:00
Julian Smart
03ab016d66 Some corrections for BC++ compilation; Latex doc corrections
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1531 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 11:42:58 +00:00
Harco de Hilster
ac0d36b523 Loads of updates/fixes. Everything is now zero-based (positions, columns,
line numbers, insertion points, the whole business). SetInsertionPoint now
works, sort of. It doesn't move the actual cursor, but WriteText will
insert at the newly set insertion point (after which the cursor is moved
anyway). This should be good enough for most uses. See further comments
in the source. BTW, WriteText now inserts text at the current point (used
to append to the end only).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1530 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 04:15:31 +00:00
Harco de Hilster
71777e2c27 Some updates to clarify definitions and behaviour of lines, columns,
positions etc. Also some general stuff added.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1529 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-31 04:11:10 +00:00
Robert Roebling
5aa5e35ade My last patch for status bar size events wasn't perfect
Added wxPython to the wxGTK dist script
  docs for wxPrivateDataObject
  Corrected penguin makefile


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-30 22:54:23 +00:00
Julian Smart
f9b1708cf5 Made wxLayoutAlgorithm more general (copes with nested sash windows)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-30 21:37:17 +00:00
Robert Roebling
884470b12e Added size event for status bar
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-30 16:43:47 +00:00
Robert Roebling
ab272c0bf8 docs for wxTextDataObjet and wxBitmapDataObject
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1525 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-01-30 15:58:31 +00:00
9 changed files with 492 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
@echo off
cd %WXWIN%\utils
rem cd %WXWIN%\utils
zip -@ -r wxPython\wxPython-%1.zip < wxPython\distrib\wxPython.rsp

View File

@@ -476,6 +476,45 @@ def EVT_CALCULATE_LAYOUT(win, func):
win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func)
# wxListCtrl
def EVT_LIST_BEGIN_DRAG(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func)
def EVT_LIST_BEGIN_RDRAG(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func)
def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func)
def EVT_LIST_END_LABEL_EDIT(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func)
def EVT_LIST_DELETE_ITEM(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func)
def EVT_LIST_DELETE_ALL_ITEMS(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func)
def EVT_LIST_GET_INFO(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func)
def EVT_LIST_SET_INFO(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func)
def EVT_LIST_ITEM_SELECTED(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func)
def EVT_LIST_ITEM_DESELECTED(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func)
def EVT_LIST_KEY_DOWN(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func)
def EVT_LIST_INSERT_ITEM(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func)
def EVT_LIST_COL_CLICK(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func)
#----------------------------------------------------------------------
@@ -576,7 +615,11 @@ class wxApp(wxPyApp):
#----------------------------------------------------------------------------
#
# $Log$
# Revision 1.10 1999/02/01 00:10:39 RD
# Added the missing EVT_LIST_ITEM_SELECTED and friends.
#
# Revision 1.9 1999/01/30 07:30:09 RD
#
# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
#
# Various cleanup, tweaks, minor additions, etc. to maintain

View File

@@ -33,11 +33,8 @@
* and things like that.
*
* $Log$
* Revision 1.5 1999/01/30 08:14:59 RD
* Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
*
* Various cleanup, tweaks, minor additions, etc. to maintain
* compatibility with the current wxWindows.
* Revision 1.6 1999/02/01 00:17:51 RD
* Added the missing EVT_LIST_ITEM_SELECTED and friends.
*
************************************************************************/
@@ -1677,7 +1674,7 @@ SWIGEXPORT(void,initwxc)() {
PyDict_SetItemString(d,"wxEVT_COMMAND_TAB_SEL_CHANGING", PyInt_FromLong((long) wxEVT_COMMAND_TAB_SEL_CHANGING));
PyDict_SetItemString(d,"wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED", PyInt_FromLong((long) wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED));
PyDict_SetItemString(d,"wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING", PyInt_FromLong((long) wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING));
PyDict_SetItemString(d,"__version__", PyString_FromString("0.5.3"));
PyDict_SetItemString(d,"__version__", PyString_FromString("0.5.4"));
PyDict_SetItemString(d,"cvar", SWIG_globals);
SWIG_addvarlink(SWIG_globals,"wxPyDefaultPosition",_wrap_wxPyDefaultPosition_get, _wrap_wxPyDefaultPosition_set);
SWIG_addvarlink(SWIG_globals,"wxPyDefaultSize",_wrap_wxPyDefaultSize_get, _wrap_wxPyDefaultSize_set);

View File

@@ -1098,6 +1098,45 @@ def EVT_CALCULATE_LAYOUT(win, func):
win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func)
# wxListCtrl
def EVT_LIST_BEGIN_DRAG(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func)
def EVT_LIST_BEGIN_RDRAG(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func)
def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func)
def EVT_LIST_END_LABEL_EDIT(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func)
def EVT_LIST_DELETE_ITEM(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func)
def EVT_LIST_DELETE_ALL_ITEMS(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func)
def EVT_LIST_GET_INFO(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func)
def EVT_LIST_SET_INFO(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func)
def EVT_LIST_ITEM_SELECTED(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func)
def EVT_LIST_ITEM_DESELECTED(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func)
def EVT_LIST_KEY_DOWN(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func)
def EVT_LIST_INSERT_ITEM(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func)
def EVT_LIST_COL_CLICK(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func)
#----------------------------------------------------------------------
@@ -1198,11 +1237,12 @@ class wxApp(wxPyApp):
#----------------------------------------------------------------------------
#
# $Log$
# Revision 1.4 1999/01/30 08:15:02 RD
# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
# Revision 1.5 1999/02/01 00:17:53 RD
# Added the missing EVT_LIST_ITEM_SELECTED and friends.
#
# Various cleanup, tweaks, minor additions, etc. to maintain
# compatibility with the current wxWindows.
# Revision 1.10 1999/02/01 00:10:39 RD
#
# Added the missing EVT_LIST_ITEM_SELECTED and friends.
#
# Revision 1.9 1999/01/30 07:30:09 RD
#

View File

@@ -9,6 +9,7 @@
# Copyright: (c) 1998 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------------
VERSION=0.5.4
# Set WXDIR to the root wxWindows directory for your system
WXDIR = $(WXWIN)
@@ -259,10 +260,19 @@ SOURCES = $(GENCODEDIR)\wx.cpp $(GENCODEDIR)\wx.py \
sources : $(SOURCES)
dist:
cd ..\..
wxPython\distrib\zipit.bat $(VERSION)
#------------------------------------------------------------------------
#
# $Log$
# Revision 1.10 1999/02/01 00:10:40 RD
# Added the missing EVT_LIST_ITEM_SELECTED and friends.
#
# Revision 1.9 1999/01/30 07:30:13 RD
#
# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
#
# Various cleanup, tweaks, minor additions, etc. to maintain

View File

@@ -33,11 +33,8 @@
* and things like that.
*
* $Log$
* Revision 1.5 1999/01/30 07:31:09 RD
* Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
*
* Various cleanup, tweaks, minor additions, etc. to maintain
* compatibility with the current wxWindows.
* Revision 1.6 1999/02/01 00:11:10 RD
* Added the missing EVT_LIST_ITEM_SELECTED and friends.
*
************************************************************************/
@@ -1729,7 +1726,7 @@ SWIGEXPORT(void,initwxc)() {
PyDict_SetItemString(d,"wxEVT_COMMAND_TAB_SEL_CHANGING", PyInt_FromLong((long) wxEVT_COMMAND_TAB_SEL_CHANGING));
PyDict_SetItemString(d,"wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED", PyInt_FromLong((long) wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED));
PyDict_SetItemString(d,"wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING", PyInt_FromLong((long) wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING));
PyDict_SetItemString(d,"__version__", PyString_FromString("0.5.3"));
PyDict_SetItemString(d,"__version__", PyString_FromString("0.5.4"));
PyDict_SetItemString(d,"cvar", SWIG_globals);
SWIG_addvarlink(SWIG_globals,"wxPyDefaultPosition",_wrap_wxPyDefaultPosition_get, _wrap_wxPyDefaultPosition_set);
SWIG_addvarlink(SWIG_globals,"wxPyDefaultSize",_wrap_wxPyDefaultSize_get, _wrap_wxPyDefaultSize_set);

View File

@@ -1110,6 +1110,45 @@ def EVT_CALCULATE_LAYOUT(win, func):
win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func)
# wxListCtrl
def EVT_LIST_BEGIN_DRAG(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func)
def EVT_LIST_BEGIN_RDRAG(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func)
def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func)
def EVT_LIST_END_LABEL_EDIT(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func)
def EVT_LIST_DELETE_ITEM(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func)
def EVT_LIST_DELETE_ALL_ITEMS(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func)
def EVT_LIST_GET_INFO(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func)
def EVT_LIST_SET_INFO(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func)
def EVT_LIST_ITEM_SELECTED(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func)
def EVT_LIST_ITEM_DESELECTED(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func)
def EVT_LIST_KEY_DOWN(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func)
def EVT_LIST_INSERT_ITEM(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func)
def EVT_LIST_COL_CLICK(win, id, func):
win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func)
#----------------------------------------------------------------------
@@ -1210,7 +1249,11 @@ class wxApp(wxPyApp):
#----------------------------------------------------------------------------
#
# $Log$
# Revision 1.4 1999/01/30 07:31:12 RD
# Revision 1.5 1999/02/01 00:11:12 RD
# Added the missing EVT_LIST_ITEM_SELECTED and friends.
#
# Revision 1.9 1999/01/30 07:30:09 RD
#
# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
#
# Various cleanup, tweaks, minor additions, etc. to maintain

View File

@@ -47,7 +47,7 @@
//---------------------------------------------------------------------------
#define __version__ "0.5.3"
#define __version__ "0.5.4"
wxPoint wxPyDefaultPosition;
wxSize wxPyDefaultSize;
@@ -156,7 +156,11 @@ extern "C" SWIGEXPORT(void,initwindows3c)();
/////////////////////////////////////////////////////////////////////////////
//
// $Log$
// Revision 1.5 1999/02/01 00:10:41 RD
// Added the missing EVT_LIST_ITEM_SELECTED and friends.
//
// Revision 1.4 1999/01/30 07:30:16 RD
//
// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
//
// Various cleanup, tweaks, minor additions, etc. to maintain

View File

@@ -0,0 +1,339 @@
#!/usr/bin/python
from wxPython.wx import *
from httplib import HTTP
from htmllib import HTMLParser
import os
import re
import formatter
__doc__ = """This is wxSlash 1.0
It's the obligatory Slashdot.org headlines reader that any modern
widget set/library must have in order to be taken seriously :-)
Usage is quite simple; wxSlash attempts to download the 'ultramode.txt'
file from http://slashdot.org, which contains the headlines in a computer
friendly format. It then displays said headlines in a wxWindows list control.
You can read articles using either Python's html library or an external
browser. Uncheck the 'browser->internal' menu item to use the latter option.
Use the settings dialog box to set how external browser is started.
This code is available under the wxWindows license, see elsewhere. If you
modify this code, be aware of the fact that slashdot.org's maintainer,
CmdrTaco, explicitly asks 'ultramode.txt' downloaders not to do this
automatically more than twice per hour. If this feature is abused, CmdrTaco
may remove the ultramode file completely and that will make a *lot* of people
unhappy.
I want to thank Alex Shnitman whose slashes.pl (Perl/GTK) script gave me
the idea for this applet.
Have fun with it,
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
"""
class HTMLTextView(wxFrame):
def __init__(self, parent, id, title='HTMLTextView', url=None):
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
wxSize(600,400))
self.mainmenu = wxMenuBar()
menu = wxMenu()
menu.Append(201, '&Open URL...', 'Open URL')
EVT_MENU(self, 201, self.OnFileOpen)
menu.Append(209, 'E&xit', 'Exit viewer')
EVT_MENU(self, 209, self.OnFileExit)
self.mainmenu.Append(menu, '&File')
self.SetMenuBar(self.mainmenu)
self.CreateStatusBar(1)
self.text = wxTextCtrl(self, -1, "", wxPyDefaultPosition,
wxPyDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
if (url):
self.OpenURL(url)
def logprint(self, x):
self.SetStatusText(x)
def OpenURL(self, url):
self.url = url
m = re.match('file:(\S+)\s*', url)
if m:
f = open(m.groups()[0],'r')
else:
m = re.match('http://([^/]+)(/\S*)\s*', url)
if m:
host = m.groups()[0]
path = m.groups()[1]
else:
m = re.match('http://(\S+)\s*', url)
if not m:
# Invalid URL
self.logprint("Invalid or unsupported URL: %s" % (url))
return
host = m.groups()[0]
path = ''
f = RetrieveAsFile(host,path,self.logprint)
if not f:
self.logprint("Could not open %s" % (url))
return
self.logprint("Receiving data...")
data = f.read()
tmp = open('tmphtml.txt','w')
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
p = HTMLParser(fmt)
self.logprint("Parsing data...")
p.feed(data)
p.close()
tmp.close()
tmp = open('tmphtml.txt', 'r')
self.text.SetValue(tmp.read())
self.SetTitle(url)
self.logprint(url)
def OnFileOpen(self, event):
dlg = wxTextEntryDialog(self, "Enter URL to open:", "")
if dlg.ShowModal() == wxID_OK:
url = dlg.GetValue()
else:
url = None
if url:
self.OpenURL(url)
def OnFileExit(self, event):
self.Close()
def OnCloseWindow(self, event):
self.Destroy()
def ParseSlashdot(f):
art_sep = re.compile('%%\r?\n')
line_sep = re.compile('\r?\n')
data = f.read()
list = art_sep.split(data)
art_list = []
for i in range(1,len(list)-1):
art_list.append(line_sep.split(list[i]))
return art_list
def myprint(x):
print x
def RetrieveAsFile(host, path='', logprint = myprint):
try:
h = HTTP(host)
except:
logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
return None
h.putrequest('GET',path)
h.putheader('Accept','text/html')
h.putheader('Accept','text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
if errcode != 200:
logprint("HTTP error code %d: %s" % (errcode, errmsg))
return None
f = h.getfile()
# f = open('/home/harm/ultramode.txt','r')
return f
class AppStatusBar(wxStatusBar):
def __init__(self, parent):
wxStatusBar.__init__(self,parent, -1)
self.SetFieldsCount(2)
self.SetStatusWidths([100,-1])
self.but = wxButton(self, 1001, "Refresh")
EVT_BUTTON(self, 1001, parent.OnViewRefresh)
self.OnSize(None)
def logprint(self,x):
self.SetStatusText(x,1)
def OnSize(self, event):
rect = self.GetFieldRect(0)
self.but.SetPosition(wxPoint(rect.x+2, rect.y+2))
# The width/height we get is false. Why? Now I use a stupid trick:
rect2 = self.GetFieldRect(1)
rect.width = rect2.x - 8;
rect.height = 25;
self.but.SetSize(wxSize(rect.width-4, rect.height-4))
# This is a simple timer class to start a function after a short delay;
# For example, if you're about to perform function f which may take a long
# time, write "Please wait" in the statusbar, then create a QuickTimer(f)
# object to automatically call f after a short delay. That way, wxWindows
# will get a chance to update the statusbar before the long function is
# called.
# FIXME: can this be done better using an OnIdle kind of thing?
class QuickTimer(wxTimer):
def __init__(self, func, wait=100):
wxTimer.__init__(self)
self.callback = func
self.Start(wait); # wait .1 second (.001 second doesn't work. why?)
def Notify(self):
self.Stop();
apply(self.callback, ());
class AppFrame(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
wxSize(650, 250))
# if the window manager closes the window:
EVT_CLOSE(self, self.OnCloseWindow);
# Now Create the menu bar and items
self.mainmenu = wxMenuBar()
menu = wxMenu()
menu.Append(209, 'E&xit', 'Enough of this already!')
EVT_MENU(self, 209, self.OnFileExit)
self.mainmenu.Append(menu, '&File')
menu = wxMenu()
menu.Append(210, '&Refresh', 'Refresh headlines')
EVT_MENU(self, 210, self.OnViewRefresh)
menu.Append(211, '&Slashdot Index', 'View Slashdot index')
EVT_MENU(self, 211, self.OnViewIndex)
menu.Append(212, 'Selected &Article', 'View selected article')
EVT_MENU(self, 212, self.OnViewArticle)
self.mainmenu.Append(menu, '&View')
menu = wxMenu()
menu.Append(220, '&Internal', 'Use internal text browser',TRUE)
menu.Check(220, true)
self.UseInternal = 1;
EVT_MENU(self, 220, self.OnBrowserInternal)
menu.Append(222, '&Settings...', 'External browser Settings')
EVT_MENU(self, 222, self.OnBrowserSettings)
self.mainmenu.Append(menu, '&Browser')
menu = wxMenu()
menu.Append(230, '&About', 'Some documentation');
EVT_MENU(self, 230, self.OnAbout)
self.mainmenu.Append(menu, '&Help')
self.SetMenuBar(self.mainmenu)
self.BrowserSettings = "netscape -remote 'OpenURL(%s, new_window)'"
# A status bar to tell people what's happening
self.sb = AppStatusBar(self)
self.SetStatusBar(self.sb)
self.list = wxListCtrl(self, 1100)
self.list.SetSingleStyle(wxLC_REPORT)
self.list.InsertColumn(0, 'Subject')
self.list.InsertColumn(1, 'Date')
self.list.InsertColumn(2, 'Posted by')
self.list.InsertColumn(3, 'Comments')
self.list.SetColumnWidth(0, 300)
self.list.SetColumnWidth(1, 150)
self.list.SetColumnWidth(2, 100)
self.list.SetColumnWidth(3, 100)
EVT_LIST_ITEM_SELECTED(self, 1100, self.OnItemSelected)
self.logprint("Connecting to slashdot... Please wait.")
# Need a longer time here. Don't really know why
self.timer = QuickTimer(self.DoRefresh, 1000)
def logprint(self, x):
self.sb.logprint(x)
def OnFileExit(self, event):
self.Destroy()
def DoRefresh(self):
f = RetrieveAsFile('slashdot.org','/ultramode.txt',self.sb.logprint)
art_list = ParseSlashdot(f)
self.list.DeleteAllItems()
self.url = []
self.current = -1
i = 0;
for article in art_list:
self.list.InsertStringItem(i, article[0])
self.list.SetItemString(i, 1, article[2])
self.list.SetItemString(i, 2, article[3])
self.list.SetItemString(i, 3, article[6])
self.url.append(article[1])
i = i + 1
self.logprint("File retrieved OK.")
def OnViewRefresh(self, event):
self.timer = QuickTimer(self.DoRefresh)
self.logprint("Connecting to slashdot... Please wait.");
def DoViewIndex(self):
if self.UseInternal:
self.view = HTMLTextView(self, -1, 'slashdot.org',
'http://slashdot.org')
self.view.Show(true)
else:
self.logprint(self.BrowserSettings % ('http://slashdot.org'))
os.system(self.BrowserSettings % ('http://slashdot.org'))
self.logprint("OK")
def OnViewIndex(self, event):
self.logprint("Starting browser... Please wait.")
self.timer = QuickTimer(self.DoViewIndex)
def DoViewArticle(self):
if self.current<0: return
url = self.url[self.current]
if self.UseInternal:
self.view = HTMLTextView(self, -1, url, url)
self.view.Show(true)
else:
self.logprint(self.BrowserSettings % (url))
os.system(self.BrowserSettings % (url))
self.logprint("OK")
def OnViewArticle(self, event):
self.logprint("Starting browser... Please wait.")
self.timer = QuickTimer(self.DoViewArticle)
def OnBrowserInternal(self, event):
if self.mainmenu.Checked(220):
self.UseInternal = 1
else:
self.UseInternal = 0
def OnBrowserSettings(self, event):
dlg = wxTextEntryDialog(self, "Enter command to view URL.\nUse %s as a placeholder for the URL.", "", self.BrowserSettings);
if dlg.ShowModal() == wxID_OK:
self.BrowserSettings = dlg.GetValue()
def OnAbout(self, event):
dlg = wxMessageDialog(self, __doc__, "wxSlash", wxOK | wxICON_INFORMATION)
dlg.ShowModal()
def OnItemSelected(self, event):
self.current = event.m_itemIndex
self.logprint("URL: %s" % (self.url[self.current]))
def OnCloseWindow(self, event):
self.Destroy()
class MyApp(wxApp):
def OnInit(self):
frame = AppFrame(NULL, -1, "Slashdot Breaking News")
frame.Show(true)
self.SetTopWindow(frame)
return true
#
# main thingy
#
if __name__ == '__main__':
app = MyApp(0)
app.MainLoop()