PySide (public license PyQT) is my preferred Python GUI toolkit. Here we explore how to test some of the widgets available and create a digital clock.

Member Avatar
Member Avatar
+3 forum 2

I am writing a game in which I need to know whether or not a user preforms an action in one second or less. I can not use time() because it measures time in seconds. If the user starts the action half-way through a second it would mess with accuracy. I am experimenting with clock(). I have got clock to work with some programs to make a delay, but not in this way to measure time: [CODE] #include <iostream> #include <ctime> using namespace std; int main() { clock_t start = clock(); cout << "press enter..."; cin.ignore(); clock_t finish = clock(); …

Member Avatar
Member Avatar
+0 forum 12

I was just mucking around with a progress feature for some software, and thought I'd just put this wee demo up of a clocky type progress thing =0) Just Copy and paste the form code and watch it run. (p.s it's in degrees, note minutes and seconds) ![55f1addda67a729e91ae90c980c39deb](/attachments/small/4/55f1addda67a729e91ae90c980c39deb.png)

Member Avatar
Member Avatar
+0 forum 2

Group, I'm trying to write some code that will read the clocktime. When it hits a predetermined time, I want it to run a routine. I know how to do this in VB.net. It would be done like this: Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick If TimeOfDay = "10:01:00 PM" Then 'Go do something important End If End Sub Unfortunately I don't know the equivalent to the same in vbScript (if there is something like it). I did find a "timer" online that counts the number of seconds from midnight. It looks like this: Function TimeIt(N) …

Member Avatar
Member Avatar
+0 forum 4

I have written this code to variably test Prim's algorithm and I am timing it using clock(). For some reason it always returns 0 as its running time. I have other code that I have used this exact implementation in and they are returning the currect running times. The code is very short and if anyone has any idea of why this is happening please let me know. I only have 4 more hours left on this project. Thanks in advance! #include <iostream> #include <stdio.h> #include <ctime> #include <cstdlib> using namespace std; int main(){ int a,b,u,v,n,i,j,ne; ne = 1; int …

Member Avatar
Member Avatar
+0 forum 4

Hi, I'm developing with a BeagleBoard Black (BBB) under Ubuntu using C. When the BBB is powered on I'm doing many time controlled tasks. My problem happens when NTP changes the clock and all my counters are not valid. Normally BBB starts with no date/time set, some seconds later (if internet connection is available) the NTP daemon changes the date/time and all my internal checks are unusable. I'm using time(). I need the real time when available to write logs and send data. But I need a time() function not dependent of current date/time to know (for example) how many …

Member Avatar
Member Avatar
+0 forum 10

Hey there! I'm currently trying to get my first text-adventure-game in python started,and I wanted to import some features that are totally unnecessary. just for the lulz. So,I want to start a timer,that starts when the game starts,and ends,when the player is dead or won the game. I want it to be like print "You won the game, %s ! You escaped in X seconds/minutes!" OR for the death function print "You lost the game, %s. You died after X seconds/minutes!" NOTE: I DO NOT NEED THE FUNCTION FOR THE DEATH OR SUCH, I JUST NEED THE TIMER FUNCTION

Member Avatar
Member Avatar
+0 forum 3

Dear Friends, i need the code for Digital Clock using 8086 in assembly language.. please help me.. i know nothing about assembly.. Please help me somebody i have found a code but its not working properly. please let me know if you want to explain the code, i'll provide it.. please help me anybody..!!!! please please!!

Member Avatar
+0 forum 0

hello. how i put a real time clock in my form ? thank you

Member Avatar
Member Avatar
+0 forum 2

**this is the code!** import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import javax.swing.JFrame; import javax.swing.JPanel; public class Clock extends JPanel{ public void paint (Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "12 1 2 3 4 5 6 7 8 9 10 11"; Font font = new Font("Courier", Font.BOLD,12); g2d.translate(100,200); FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector gv = font.createGlyphVector(frc, s); int length = gv.getNumGlyphs(); for(int i = 0; i < length; i++) { Point2D p = gv.getGlyphPosition(i); AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY()); at.rotate((double) i / …

Member Avatar
Member Avatar
+0 forum 3

How to get the correct and current date and time in vb.net even a user change the computer's system clock? Let's say the correct and current date and time is 7/20/2012 11:00 AM then I change the clock to 7/19/2012 11:00 AM. How to retrieve the original date(7/20/2012) in vb.net? Any ideas? I am planning to put this feature on my project(attendance monitoring system) to avoid a user changing the system clock. Thank you for any help.

Member Avatar
Member Avatar
+0 forum 2

I have trouble trying to create a clock java program that asks for user's input for hours and minutes. When it asks the user for their input, the clock program is suppose to set it to that time using the hour hand and the minute hand, but for some reason I keep getting an invalid input message. I don't really know where the problem is coming from and how to fix it :( Any input/advice/help would be greatly appreciated!! (I am still a new java programmer so please excuse my horrible structure x.x ) Here is my code: **Clock.java** import …

Member Avatar
Member Avatar
+0 forum 1

This is a code which sorts arrays. I use clock_t to determine the processing time for my code. However, it always stacks with the time taken from before. It looks like it's just adding the results. [code] int main(int argc, char *argv[]) {unsigned long n;//size of array -- long for big numbers of n int choice, choice2, sort;//numbers corresponding to the choices(switch) clock_t Begin, End; float elapTicks, elapMilli; wrongchoice://goto function -- bringing back to this point after entering wrong choice cout<<"===============================… cout<<"\t\t\tChoose the order of the output:\n\t\t\t\t[1] Random-Descending\n\t\t\t\t[2] Ascending-Descending\n\t\t\t\t[3] Descending-Ascending\n\t\t\t\t[4] Random-Ascending\n\t\t\tChoice: "; cin>>choice; cout<<"\t\t\tIndicate size of array: "; cin>>n; long …

Member Avatar
Member Avatar
+0 forum 1

I've this code. I need to do several experiments to obtain de average time it takes to do some methods. Instead of re-running and re-running the program, I want to put a segment of the code in a FOR bucle. The problem is that my program never ends,it stays looping forever Here is part of my code [CODE]int a= 0; for (a= 0; a= 20; a++){ // I WANT IT TO REPEAT FROM HERE (20 times) std::clock_t start; double duration; // Populates the vector for(i=0; i<n; i++) v[i] = i; /* // Original vector cout << "Current Contents:\n"; for(i=0; i<v.size(); …

Member Avatar
Member Avatar
+0 forum 1

I've been given a basic form of programming to do. And I simply cannot figure it out. I know this topic has been covered several times before. But each of them going around the one crucial step that I need to complete my programming. My instructor insists that the 24 hour clock is given in HH:MM time and not as two separate factors. If you want me to post the bits of coding I have in here I can, but it's not much and probably will not contribute much. I'm thankful for any bits of help I can get. If …

Member Avatar
Member Avatar
+0 forum 12

Just fooling around I came across an issue updating a digital-clock like label. This: [CODE]self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime()) self.clock=ttk.Label(self,text=self.now) self.clock.pack() while True: self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime()) self.clock['text']=self.now[/CODE] simply freezes the program, I've managed to get it to update on certain events like the user hitting a button but I'd like it to continuously update. Any ideas? [B]EDIT:[/B] I got this to work using configure, but why does that work and not this? [B]Double EDIT:[/B]After some thinking I decided it was because the program was stuck in an infinite while loop, however this simply revisits the method.

Member Avatar
Member Avatar
+0 forum 2

hi.. i used this code to display a clock. [CODE]<script type="text/javascript"> var int=self.setInterval("clock()",1000); function clock() { var d=new Date(); var t=d.toLocaleTimeString(); document.getElementById("apDiv1").innerHTML=t; } </script>[/CODE] in firefox it displays like this 7:25:00 PM and in Chrome 19:25:39 i want to show a similar clock as in firefox in Chrome. How can i change it?

Member Avatar
Member Avatar
+0 forum 5

I have seen many beautiful clocks using images and and canvas and flash. So I thought of developing one with pure HTML,CSS3 and javascript, no images at all. This clock can be completely design using CSS. A brief description of Javascript used:- 'AnalogClock' is the name of the class which creates a clock. You can simply create as many instance of the clock on page (keeping in mind the performance). This how you can create a clock:- 1. Include all the css in the page 2. Then create a container for the clock on page [CODE=html]<div id="aclock"></div>[/CODE] 3. Create an …

Member Avatar
Member Avatar
+0 forum 1

Hi, I am able to create a clock in a console c++ app...like this one show UTC hours:[CODE]#include "stdafx.h" #include <iostream> #include <windows.h> #include <stdio.h> void main() { SYSTEMTIME st, lt; GetSystemTime(&st); GetLocalTime(&lt); std::cout << st.wHour << std::endl; std::cin.get(); }[/CODE] But I am not able to create this with the .NET Framework 3.5, I mean Windows Forms. I want to assign HOURS : MINUTES : SECONDS to a label. Can you help me out? Regards

Member Avatar
Member Avatar
+0 forum 3

The code I wrote for a digital clock always falls behind the clock in my windows 7 taskbar after being run for like 2-3 mins. Why? Here's the code: [CODE]#include <stdio.h> #include <time.h> #include <windows.h> int main() { int h,m,s; time_t epoch_time; struct tm *tm_p; epoch_time = time( NULL ); tm_p = localtime( &epoch_time ); h=tm_p->tm_hour%12; m=tm_p->tm_min; s=tm_p->tm_sec; while(1) { if(s>59) { m=m+1; s=0; } if(m>59) { h=h+1; m=0; } if(h>11) { h=0; m=0; s=0; } Sleep(1000); s++; // trying something I learned (s=s+1) system ("cls"); printf(" %d:%d:%d",h,m,s); } }[/CODE]

Member Avatar
Member Avatar
+0 forum 3

Hi. Strange thing: When I change the clock of the PC (XP SP2), something link current time is 12:03:34 to 12:05:34, my application crash. nothing in application log, though every method has try-catch. nothing in event log... Can anyone help? Thanks.

Member Avatar
Member Avatar
+0 forum 2

Hello everyone! I'm making a tetris program, and now I'm stucked a bit. I have to use the simple getch() function, but in a special way. I need to use it for exact time, and when the time is up, I need to break the function, even if I haven't got any characters entered. It's for the horizontal movement of a brick - you have time to move it horizontally, but when the time is up, it moves one pixel vertically. I hope, I was understandable.

Member Avatar
Member Avatar
+0 forum 1

I have been frustrated by the lack of a time unit in all the C/C++ std librarys (hope I've got the right wording!). What is a function that I could use. I don't care if I write it or if it is in a library. Thanx in advance!

Member Avatar
Member Avatar
+0 forum 2

I can't figure out how to get rid of this race condition I'm getting in my synthesizable verilog code. Basically, I'm generating an input value for a module, and at positive edge of my clock I capture that value at my module. The problem is that I want the value post-clock-rise and not pre-clock-rise. Has anyone had this problem before? It seems like it would be common... Any help you can give me would be great.

Member Avatar
Member Avatar
+0 forum 1

I am new to VB coding so I'm trying some easy projects. I figured an alarm clock would be a good place to start. But I'm Having a hard time with the MP3 Part of it all. I want a pre-selected MP3 to start, when my timer2 is = to the time of day. But i Have never really used MP3's in any project. So dose anyone know how i would go about. A. Adding a MP3 to the coding in the background and then. B. Calling on it when the alarm goes off.

Member Avatar
Member Avatar
+0 forum 5

I need to put a digital (or analogic) clock in a pygtk window with a exit button. I was looking a example with Tkinter but I do not know how to integrate in a pygtk window [ICODE] from Tkinter import * import time root = Tk() time1 = '' clock = Label(root, font=('times', 20, 'bold'), bg='white') clock.pack(fill=BOTH, expand=1) def tick(): global time1 # get the current local time from the PC time2 = time.strftime('%H:%M:%S') # if time string has changed, update it if time2 != time1: time1 = time2 clock.config(text=time2) # calls itself every 200 milliseconds # to update the …

Member Avatar
Member Avatar
+0 forum 2

i missed lecture today and this is what they did in class. im not sure how to complete this. hope you all can help me out. [code] class Clock { // Declare fields of the class // 0 <= hours < 24, 0 <= minutes < 60, 0 <= seconds < 60 private int hours, minutes, seconds; Clock(int hh, int mm, int ss) //constructor { } //increase time by sec seconds public void incrementSeconds(int sec) { } //increase time by min minutes public void incrementMinutes(int min) { } //increase time by hh hours, //if hours reach 24, simply wrap around …

Member Avatar
Member Avatar
+0 forum 6

Hi guys, im not well experienxed please help, i want to code a digital running time with the colon dots flickering to show that the time is running anyone can offer help will be very usefull.

Member Avatar
Member Avatar
+0 forum 5

The End.