Tags » Python

Share Your Code of Love : PyPI

Okay. This is one is going to be awesome! :D

In this post I am going to share how to share your package to PyPI… 934 more words

Programming

Python - If Statement

Most of the time, every programmer feels the need to compare on or two values of variables in your program. Same as most of the programming languages, Python also has its syntax for the If Statement. 55 more words

Introduction

Urwid Python - Tạo timer count down với urwid (curses)

import urwid
import time
import sys

class CountDown:

    def __init__(self, seconds):
        self.seconds = seconds
        self.palette = [('start', 'yellow', ''),
                        ('finish', 'dark red', '')
                        ]
        self.alarm = None

    def main(self):
        self.setup_view()
        self.main_loop = urwid.MainLoop(self.view,
                                        palette=self.palette,
                                        unhandled_input=self.keypress)
        self.alarm = self.main_loop.set_alarm_in(1, self.start)
        self.main_loop.run()

    def keypress(self, key):
        if key in ('q', 'Q'):
            raise urwid.ExitMainLoop()

    def setup_view(self):
        color = 'start' if self.seconds > 3 else 'finish'
        self.count_text = urwid.BigText(
            time.strftime('%H:%M:%S', time.gmtime(self.seconds)),
            urwid.font.HalfBlock6x5Font())
        self.view = urwid.Padding(self.count_text, 'center', width='clip')
        self.view = urwid.AttrMap(self.view, color)
        self.view = urwid.Filler(self.view, 'middle')

    def start(self, loop=None, data=None):
        self.seconds = self.seconds - 1
        if self.seconds < 0:
            return
        self.setup_view()
        loop.widget = self.view
        self.alarm = loop.set_alarm_in(1, self.start)

if __name__ == '__main__':
    try:
        sourcetime = sys.argv[1]
        sourcetime = map(lambda x: int(x), init.split(':'))
        total_seconds = sourcetime[0] * 3600 + \
            sourcetime[1] * 60 + sourcetime[2]
        c = CountDown(total_seconds)
        c.main()
    except Exception, KeyboardInterrupt:
        pass

Python

on-track

 

Given a distance of 20 px between the line splines, rotating the hachure 45º increases the required offset distance to (20^2 + 20^2)^0.5.

Playing card detection using OpenCV (Mark V)

I am busy building a poker bot using a webcam, my Raspberry Pi computer and some Python code. Why? Because Peters, my Dutch lodger, has won so many late-night card games against me that he now owns the deeds to my house. 1,324 more words

Technology

MVC Nedir?

MVC’nin açılımı MODEL-VIEW-CONTROLLER’ın baş harflerinden gelmektedir. Katmanlı bir mimari sunmaktadır ve bu sayede uygulamanın kullanıcı arayüzü ile business kısmını birbirinden ayırmaktadır. Bir çok platformda tercih edilmektedir. 255 more words

Java