This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App(QWidget): | |
def __init__(self): | |
super().__init__() | |
## Set main window attributes | |
self.title = 'Photo Album Viewer' | |
self.left = 0 | |
self.top = 0 | |
self.width = 800 | |
self.height = 600 | |
self.resizeEvent = lambda e : self.on_main_window_resize(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Widget for selecting an image in the directory to display | |
## Makes a vertical scrollable widget with selectable image thumbnails | |
class ImageFileSelector(QWidget): | |
def __init__(self, parent=None, album_path='', display_image=None): | |
QWidget.__init__(self, parent=parent) | |
self.display_image = display_image | |
self.grid_layout = QGridLayout(self) | |
self.grid_layout.setVerticalSpacing(30) | |
## Get all the image files in the directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Widget for the single image that is currently on display | |
class DisplayImage(QWidget): | |
def __init__(self, parent=None): | |
QWidget.__init__(self) | |
self.parent = parent | |
self.pixmap = QPixmap() | |
self.label = QLabel(self) | |
self.assigned_img_full_path = '' | |
def update_display_image(self, path_to_image=''): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEFAULT_IMAGE_ALBUM_DIRECTORY = './my-album/' | |
## Check that a file name has a valid image extension for QPixmap | |
def filename_has_image_extension(filename): | |
valid_img_extensions = \ | |
['bmp', 'gif', 'jpg', 'jpeg', 'png', 'pbm', 'pgm', 'ppm', 'xbm', 'xpm'] | |
filename = filename.lower() | |
extension = filename[-3:] | |
four_char = filename[-4:] ## exclusively for jpeg | |
if extension in valid_img_extensions or four_char in valid_img_extensions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from os import listdir | |
from os.path import isfile, join | |
from PyQt5.QtCore import Qt, QSize | |
from PyQt5.QtWidgets import * | |
from PyQt5.QtGui import QPixmap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('./request.js'); | |
const array = [1, 2, 3, 4, 5]; | |
(async function() { | |
while (array.length > 0) { | |
// Dequeue the first element in the array | |
// Note that this modifies the array! | |
const el = array.shift(); | |
const response = await request({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('./request.js'); | |
const array = [1, 2, 3, 4, 5]; | |
(async function() { | |
for (let i = 0; i < array.length; i++) { | |
const response = await request({ | |
method: 'GET', | |
hostname: 'httpbin.org', | |
path: '/get?myArg=' + array[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('./request.js'); | |
function forEachWithCallback(callback) { | |
const arrayCopy = this; | |
let index = 0; | |
const next = () => { | |
index++; | |
if (arrayCopy.length > 0) { | |
callback(arrayCopy.shift(), index, next); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requests==2.22.0 | |
lxml==4.4.1 | |
google==2.0.2 | |
beautifulsoup4==4.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const submitButton = document.getElementById('submitButton'); | |
const chatbotInput = document.getElementById('chatbotInput'); | |
const chatbotOutput = document.getElementById('chatbotOutput'); | |
submitButton.onclick = userSubmitEventHandler; | |
chatbotInput.onkeyup = userSubmitEventHandler; | |
function userSubmitEventHandler(event) { | |
if ( | |
(event.keyCode && event.keyCode === 13) || |
NewerOlder