Skip to content

Commit 80a4c30

Browse files
committed
Polishes the rough edges of CTK.Radio. It also implements a new
CTK.RadioText() class and adds a test program to checkout the functionality. git-svn-id: svn://cherokee-project.com/CTK/trunk@5493 5dc97367-97f1-0310-9951-d761b3857238
1 parent b941c46 commit 80a4c30

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

CTK/Radio.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# Authors:
44
# Taher Shihadeh
5+
# Alvaro Lopez Ortega
56
#
67
# Copyright (C) 2010 Alvaro Lopez Ortega
78
#
@@ -20,9 +21,9 @@
2021
# 02110-1301, USA.
2122
#
2223

23-
__author__ = 'Taher Shihadeh <[email protected]>'
24-
2524
from Widget import Widget
25+
from Box import Box
26+
from RawHTML import RawHTML
2627
from Container import Container
2728
from Server import cfg
2829
from util import *
@@ -52,7 +53,19 @@ def Render (self):
5253

5354
# Render the widget
5455
render = Widget.Render (self)
55-
render.html += HTML % ({'id': self.id,
56-
'props': props_to_str (new_props)})
56+
render.html += HTML %({'id': self.id,
57+
'props': props_to_str (new_props)})
5758
return render
5859

60+
61+
class RadioText (Box):
62+
def __init__ (self, txt, props={}):
63+
Box.__init__ (self)
64+
65+
self.radio = Radio (props.copy())
66+
self += self.radio
67+
68+
self.text = Box ({'class': 'radio-text'}, RawHTML(txt))
69+
self += self.text
70+
71+
self.text.bind('click', "$('#%s').attr('checked', true);" %(self.radio.id))

CTK/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
from List import List, ListEntry
6565
from ProgressBar import ProgressBar
6666
from Downloader import Downloader, DownloadEntry_Factory
67-
from Radio import Radio
67+
from Radio import Radio, RadioText
6868
from XMLRPCProxy import XMLRPCProxy
6969
from AjaxUpload import AjaxUpload
7070
from Paginator import Paginator

tests/test16.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import CTK
4+
5+
def default():
6+
page = CTK.Page()
7+
page += CTK.RadioText("option 1", {'name': 'test16', 'value': 'a'})
8+
page += CTK.RadioText("option 2", {'name': 'test16', 'value': 'b'})
9+
page += CTK.RadioText("option 3", {'name': 'test16', 'value': 'c'})
10+
return page.Render()
11+
12+
CTK.publish ('', default)
13+
CTK.run (port=8000)

0 commit comments

Comments
 (0)