#!/usr/bin/wish package require Tk package require opt source czrss.tcl namespace eval ::rssgui { variable counter 0 proc init {} { # weißer Hintergrund option add *background white . configure -background white # Hauptfenster text .text -relief flat -wrap word \ -selectbackground blue -highlightthickness 0 \ -yscrollcommand {.sby set} grid .text -row 1 -column 1 -sticky nesw scrollbar .sby -orient vert -highlightthickness 0 \ -command {.text yview} grid .sby -row 1 -column 2 -sticky ns # Nicht im Heft abgedruckt: frame .buttons grid .buttons -row 2 -columnspan 3 -sticky e image create photo aus -file aus.gif button .buttons.exit -command {exit 0} \ -image aus -relief flat \ -highlightthickness 0 pack .buttons.exit -anchor e # Ende des zusätzlichen Abschnitts grid rowconfigure . 0 -minsize 10 grid rowconfigure . 1 -weight 1 grid rowconfigure . 2 -minsize 10 grid columnconfigure . 0 -minsize 10 grid columnconfigure . 1 -weight 1 grid columnconfigure . 3 -minsize 10 # Text konfigurieren .text tag configure title -foreground steelblue \ -font {Helvetica 12} -spacing1 5 -spacing3 5 .text tag configure description -foreground black -elide true \ -spacing1 10 -lmargin1 20 -lmargin2 10 -spacing3 5 .text tag configure gerade -background whitesmoke .text tag configure ungerade -background white .text tag configure sichtbar -elide false .text conf -state disabled } proc setFeed {url} { set doc [::czrss::doc create %AUTO% $url] set channel [$doc channel] wm title . [$channel title] .text conf -state normal .text delete 1.0 end foreach item [$doc items] { insertMessage [$item title] [$item description] [$item link] } .text conf -state disabled } proc insertMessage {title description url} { variable counter if {[expr [incr counter] % 2]} { set zeile gerade } else { set zeile ungerade } .text insert end "$title\n" [list $zeile title "t$counter"] .text insert end "$description\n" [list $zeile description "d$counter"] .text tag bind "t$counter" [list ::rssgui::enterTag "$counter"] .text tag bind "t$counter" [list ::rssgui::startBrowser $url] .text tag bind "d$counter" [list ::rssgui::startBrowser $url] } proc enterTag {id} { set start [lindex [.text tag nextrange "t$id" 1.0 end] 0] set end [lindex [.text tag nextrange "d$id" 1.0 end] 1] .text tag add sichtbar $start $end .text tag bind sichtbar [list ::rssgui::leaveTag $id] } proc leaveTag {id} { .text tag remove sichtbar 1.0 end } proc startBrowser {url} { foreach browser {galeon firefox mozilla konqueror netscape opera} { set binary [lindex [auto_execok $browser] 0] if {[string length $binary]} { puts "$binary $url" catch {exec $binary $url &} break } } } } tcl::OptProc main { {url "RSS-Feed, z.B. http://www.tagesschau.de/newsticker.rdf" } } { rssgui::init rssgui::setFeed $url } if {[catch {eval main $argv} res]} { puts stderr $res }