PyQt ProgressBar: Update progress from other threads

Categories: Python; Tagged with: ; @ May 14th, 2015 23:40

Issue 1: UI is no responding when the progress is running


Create new thread to perform the progress:
http://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt

Issue 2: QThread: Destroyed while thread is still running

Try to keep a reference:
http://stackoverflow.com/questions/8359469/python-threading-thread-scopes-and-garbage-collection

Issue 3: QWidget::repaint: Recursive repaint detected


Use single to update progress:
http://stackoverflow.com/questions/9682376/progress-bar-with-pyqt

 

Example: UploadThread:

class UploadTaskQtThread(QtCore.QThread):
    tick = QtCore.pyqtSignal(int, name="upload_changed")

    def __init__(self, client, local_path, remote_path):
        QtCore.QThread.__init__(self)
        self.client = client
        self.local_path = local_path
        self.remote_path = remote_path
        
    def on_progress(self, progress):
        self.tick.emit(progress * 100)
        
    def run(self):
        self.client.upload_file(self.local_path, self.remote_path, self.on_progress)

Client:

    def upload(self, local_file_path, remote_path):
        self.upload_thread = UploadTaskQtThread(client, local_file_path, remote_path)
        self.upload_thread.start()
        self.upload_thread.tick.connect(ui.progressBar.setValue)

Maven: Understanding Lifecycle, Phase and Plugin Goal by code

Categories: Development NotesJava February 11th, 2015 23:24

Lifecycle

There are same built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project’s site documentation.

the default lifecycle includes many phases, e.g: validate, initialize…compile, test, package, integration-test, verify, install and deploy.  check Maven 3 components.xml;

If you run one phase, e.g. install, it will execute not only that phase (install), but also every phase prior to the install phase;

Phases

A Build Phase is Made Up of Plugin Goals;

for maven 3.1, compile phase is using: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile;  get more details from default-bindings.xml

Plugin Goal

A plugin may have one or more goals wherein each goal represents a capability of that plugin.

plugins can contain information that indicates which lifecycle phase to bind a goal to. Note that adding the plugin on its own is not enough information – you must also specify the goals you want to run as part of your build. A plugin goal may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation.

pom configuration examples:

maven compile: http://maven.apache.org/plugins/maven-compiler-plugin/usage.html

maven javadoc: http://maven.apache.org/plugins/maven-javadoc-plugin/usage.html

IntelliJ 14 Jetty integration

Categories: Development NotesJava November 30th, 2014 23:02

Bug with Jetty 9.2.5?

Tried Jetty jetty-distribution-9.2.5.v20141112 but got this Error when configuring the jetty server:
”start.d\http.ini not found”;

cannot find jetty.base when starting the sever:

WARNING: Missing Required File: ${jetty.base}\lib\alpn\alpn-boot-8.1.0.v20141016.jar

Use Jetty 8?

works fine with Jetty 8.

.Net GridView: Using LINQ and List as DataSource

Categories: .Net June 25th, 2014 23:52

Requirement:  create a GridView using LINQ and List;

image

Code:

Set DataSource:

GridViewUsers.DataSource = userManager.GetDataSource();
GridViewUsers.DataBind();

UserManager:

private List<User> users = new List<User>();

public List<User> GetDataSource() {
     var query =
         from user in users
         select user;
     return query.ToList();
}

Excel: Use Conditional Formatting to format cells by formula

Categories: Development Notes; Tagged with: ; @ May 15th, 2014 23:31

Requirement:

As a (junior) Excel user, I want to compare two columns and change the background colour  for the cells which is not consistent.

SNAGHTML8b7b0b

 

Steps:

1. Create New Rule:

you may select the B2, and click Conditional Formatting > New Rule:

image

Configure the formula and the format.

2. Apply the the rule:

You may right click the ‘+’and then drug,  select the ‘Fill formatting Only’ when drop.

image

Or you can use Conditional Formatting > Manage Rules:

image

to change the “Applies to…” and then “Apply”

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.