This file contains hidden or 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
from nicegui import ui | |
def update(): | |
chart.options['chart']['type'] = chart_type.value | |
chart.update() | |
chart_type = ui.radio(['line', 'area', 'bar', 'column'], value='column', on_change=update).props('inline') | |
grades = {'Ali': [12, 16, 18, 20], | |
'Maryam': [19, 20, 18, 15], |
This file contains hidden or 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
from enum import Enum | |
from nicegui import ui | |
from nicegui.elements.html import Html | |
from nicegui.functions.timer import Timer | |
Direction = Enum('Direction', ['Up', 'Down', 'Right', 'Left']) | |
class Position(): | |
def __init__ (self, x, y): |
This file contains hidden or 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
from enum import Enum | |
from nicegui import ui | |
Direction = Enum('Direction', ['Up', 'Down', 'Right', 'Left']) | |
def build_svg(grid_size, cell_size) -> str: | |
width = cell_size * grid_size + 1 | |
height = cell_size * grid_size + 1 |
This file contains hidden or 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 math | |
from nicegui import app, ui | |
class SceneState(): | |
def __init__(self) -> None: | |
self.stage = '' | |
self.road_parts = [] | |
self.light_poles = [] | |
self.car = None | |
self.refresh_rate = 20 |
This file contains hidden or 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
from nicegui import app, ui | |
refresh_rate = 60 | |
def play(): | |
timer.active = not timer.active | |
def update_scene(): | |
movement = 1 | |
delta = movement / refresh_rate |
This file contains hidden or 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 random | |
from nicegui import events, ui | |
from nicegui.events import KeyEventArguments | |
def handle_click(e: events.SceneClickEventArguments): | |
hit = e.hits[0] | |
name = hit.object_name or hit.object_id | |
notify(f'You clicked on the {name} at ({hit.x:.2f}, {hit.y:.2f}, {hit.z:.2f})') | |
clicked_box = next(filter(lambda x: x.name == name, scene_state.boxes), None) | |
if clicked_box: |
This file contains hidden or 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 math | |
from graphics import * | |
from typing import List | |
def main(size): | |
win = GraphWin("My Circle", size, size) | |
center = size / 2 | |
radius = 100 |
This file contains hidden or 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
/// Question: | |
/// Write a C# code to analysis the multiple waves of an earthquake signal | |
/// Chat GPT Answer: | |
using System; | |
using System.Collections.Generic; | |
namespace EarthquakeAnalysis |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Trading | |
{ | |
// A class representing a single order in the order book | |
public class Order | |
{ | |
public int Id { get; set; } |
This file contains hidden or 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 operator | |
# Define a dictionary of supported operations and their corresponding | |
# functions from the operator module | |
operators = { | |
"+": operator.add, | |
"-": operator.sub, | |
"*": operator.mul, | |
"/": operator.truediv, | |
} |
NewerOlder