Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 38591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:43:55+00:00 2026-05-10T14:43:55+00:00

I have been playing with the Ruby library shoes. Basically you can write a

  • 0

I have been playing with the Ruby library ‘shoes’. Basically you can write a GUI application in the following way:

Shoes.app do   t = para 'Not clicked!'   button 'The Label' do     alert 'You clicked the button!' # when clicked, make an alert     t.replace 'Clicked!' # ..and replace the label's text   end end 

This made me think – how would I design a similarly nice-to-use GUI framework in Python? One that doesn’t have the usual tyings of basically being wrappers to a C* library (In the case of GTK, Tk, wx, QT etc etc)

Shoes takes things from web devlopment (like #f0c2f0 style colour notation, CSS layout techniques, like :margin => 10), and from ruby (extensively using blocks in sensible ways)

Python’s lack of ‘rubyish blocks’ makes a (metaphorically)-direct port impossible:

def Shoeless(Shoes.app):     self.t = para('Not clicked!')      def on_click_func(self):         alert('You clicked the button!')         self.t.replace('clicked!')      b = button('The label', click=self.on_click_func) 

No where near as clean, and wouldn’t be nearly as flexible, and I’m not even sure if it would be implementable.

Using decorators seems like an interesting way to map blocks of code to a specific action:

class BaseControl:     def __init__(self):         self.func = None      def clicked(self, func):         self.func = func      def __call__(self):         if self.func is not None:             self.func()  class Button(BaseControl):     pass  class Label(BaseControl):     pass  # The actual applications code (that the end-user would write) class MyApp:     ok = Button()     la = Label()      @ok.clicked     def clickeryHappened():         print 'OK Clicked!'  if __name__ == '__main__':     a = MyApp()     a.ok() # trigger the clicked action 

Basically the decorator function stores the function, then when the action occurred (say, a click) the appropriate function would be executed.

The scope of various stuff (say, the la label in the above example) could be rather complicated, but it seems doable in a fairly neat manner..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:43:56+00:00Added an answer on May 10, 2026 at 2:43 pm

    You could actually pull this off, but it would require using metaclasses, which are deep magic (there be dragons). If you want an intro to metaclasses, there’s a series of articles from IBM which manage to introduce the ideas without melting your brain.

    The source code from an ORM like SQLObject might help, too, since it uses this same kind of declarative syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Java is confusing because everything is passed by value. However… May 12, 2026 at 12:45 am
  • Editorial Team
    Editorial Team added an answer This is likely going to be called a micro optimisation.… May 12, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer Lucene.NET. Here's a blog post about how I used it… May 12, 2026 at 12:44 am

Related Questions

I have been interested in learning Rails for some time now and feel now
I went to school for programming years ago and when I got out I
A lot of questions have been asked about gem support in Shoes, but none
I'm playing around with making a simple terminal-based game with Ruby, and I'm currently

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.